directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r161428 - directory/network/trunk/src/java/org/apache/mina/common/ByteBuffer.java
Date Fri, 15 Apr 2005 09:58:52 GMT
Author: trustin
Date: Fri Apr 15 02:58:51 2005
New Revision: 161428

URL: http://svn.apache.org/viewcvs?view=rev&rev=161428
Log:
ByteBuffer pool can allocate smaller buffers now.

Modified:
    directory/network/trunk/src/java/org/apache/mina/common/ByteBuffer.java

Modified: directory/network/trunk/src/java/org/apache/mina/common/ByteBuffer.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/common/ByteBuffer.java?view=diff&r1=161427&r2=161428
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/common/ByteBuffer.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/common/ByteBuffer.java Fri Apr 15 02:58:51
2005
@@ -52,6 +52,8 @@
  */
 public final class ByteBuffer
 {
+    private static final int MINIMUM_CAPACITY = 1;
+
     private static final Stack[] heapBufferStacks = new Stack[] {
             new Stack(), new Stack(), new Stack(), new Stack(),
             new Stack(), new Stack(), new Stack(), new Stack(),
@@ -60,8 +62,8 @@
             new Stack(), new Stack(), new Stack(), new Stack(),
             new Stack(), new Stack(), new Stack(), new Stack(),
             new Stack(), new Stack(), new Stack(), new Stack(),
-            new Stack(), };
-
+            new Stack(), new Stack(), new Stack(), new Stack(), };
+    
     private static final Stack[] directBufferStacks = new Stack[] {
             new Stack(), new Stack(), new Stack(), new Stack(),
             new Stack(), new Stack(), new Stack(), new Stack(),
@@ -70,7 +72,7 @@
             new Stack(), new Stack(), new Stack(), new Stack(),
             new Stack(), new Stack(), new Stack(), new Stack(),
             new Stack(), new Stack(), new Stack(), new Stack(),
-            new Stack(), };
+            new Stack(), new Stack(), new Stack(), new Stack(), };
     
     /**
      * Returns the direct buffer which is capable of the specified size.
@@ -101,7 +103,7 @@
             buf = ( ByteBuffer ) stack.pop();
             if( buf == null )
             {
-                buf = new ByteBuffer( 16 << idx, direct );
+                buf = new ByteBuffer( MINIMUM_CAPACITY << idx, direct );
             }
         }
 
@@ -124,7 +126,7 @@
     
     private static int getBufferStackIndex( Stack[] bufferStacks, int size )
     {
-        int targetSize = 16;
+        int targetSize = MINIMUM_CAPACITY;
         int stackIdx = 0;
         while( size > targetSize )
         {



Mime
View raw message