You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by tr...@apache.org on 2008/05/23 04:37:23 UTC

svn commit: r659375 - /mina/branches/buffer/core/src/main/java/org/apache/mina/queue/DefaultByteBufferQueue.java

Author: trustin
Date: Thu May 22 19:37:22 2008
New Revision: 659375

URL: http://svn.apache.org/viewvc?rev=659375&view=rev
Log:
Removed unnecessary code duplication in DefaultByteBufferQueue

Modified:
    mina/branches/buffer/core/src/main/java/org/apache/mina/queue/DefaultByteBufferQueue.java

Modified: mina/branches/buffer/core/src/main/java/org/apache/mina/queue/DefaultByteBufferQueue.java
URL: http://svn.apache.org/viewvc/mina/branches/buffer/core/src/main/java/org/apache/mina/queue/DefaultByteBufferQueue.java?rev=659375&r1=659374&r2=659375&view=diff
==============================================================================
--- mina/branches/buffer/core/src/main/java/org/apache/mina/queue/DefaultByteBufferQueue.java (original)
+++ mina/branches/buffer/core/src/main/java/org/apache/mina/queue/DefaultByteBufferQueue.java Thu May 22 19:37:22 2008
@@ -438,18 +438,7 @@
         }
 
         // Otherwise, read byte by byte. (inefficient!)
-        int value = 0;
-        for (int bytesToRead = 2; bytesToRead > 0; bytesToRead --) {
-            value = value << 8 | e.get();
-            remaining --;
-            length --;
-            if (remaining == 0) {
-                e = safeElement();
-                remaining = e.remaining();
-            }
-        }
-
-        return applyByteOrder((short) value);
+        return applyByteOrder((short) readByteByByte(2));
     }
 
     public int    removeInt() {
@@ -471,18 +460,7 @@
         }
 
         // Otherwise, read byte by byte. (inefficient!)
-        int value = 0;
-        for (int bytesToRead = 4; bytesToRead > 0; bytesToRead --) {
-            value = value << 8 | e.get();
-            length --;
-            remaining --;
-            if (remaining == 0) {
-                e = safeElement();
-                remaining = e.remaining();
-            }
-        }
-
-        return applyByteOrder(value);
+        return applyByteOrder((int) readByteByByte(4));
     }
 
     public long   removeLong() {
@@ -504,18 +482,7 @@
         }
 
         // Otherwise, read byte by byte. (inefficient!)
-        long value = 0;
-        for (int bytesToRead = 8; bytesToRead > 0; bytesToRead --) {
-            value = value << 8 | e.get();
-            length --;
-            remaining --;
-            if (remaining == 0) {
-                e = safeElement();
-                remaining = e.remaining();
-            }
-        }
-
-        return applyByteOrder(value);
+        return applyByteOrder(readByteByByte(8));
     }
 
     public float  removeFloat() {