cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r1148805 - /cassandra/trunk/src/java/org/apache/cassandra/utils/ByteBufferUtil.java
Date Wed, 20 Jul 2011 14:53:20 GMT
Author: jbellis
Date: Wed Jul 20 14:53:19 2011
New Revision: 1148805

URL: http://svn.apache.org/viewvc?rev=1148805&view=rev
Log:
clarify that BBU.read doesn't allocate arrays unnecessarily

Modified:
    cassandra/trunk/src/java/org/apache/cassandra/utils/ByteBufferUtil.java

Modified: cassandra/trunk/src/java/org/apache/cassandra/utils/ByteBufferUtil.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/utils/ByteBufferUtil.java?rev=1148805&r1=1148804&r2=1148805&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/utils/ByteBufferUtil.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/utils/ByteBufferUtil.java Wed Jul 20 14:53:19
2011
@@ -382,20 +382,12 @@ public class ByteBufferUtil
 
     private static ByteBuffer read(DataInput in, int length) throws IOException
     {
-        ByteBuffer array;
-
         if (in instanceof FileDataInput)
-        {
-            array = ((FileDataInput) in).readBytes(length);
-        }
-        else
-        {
-            byte[] buff = new byte[length];
-            in.readFully(buff);
-            array = ByteBuffer.wrap(buff);
-        }
+            return ((FileDataInput) in).readBytes(length);
 
-        return array;
+        byte[] buff = new byte[length];
+        in.readFully(buff);
+        return ByteBuffer.wrap(buff);
     }
 
     /**



Mime
View raw message