[jbosscache-commits] JBoss Cache SVN: r7380 - core/trunk/src/main/java/org/jboss/cache/util.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Mon Jan 5 12:54:59 EST 2009


Author: jason.greene at jboss.com
Date: 2009-01-05 12:54:59 -0500 (Mon, 05 Jan 2009)
New Revision: 7380

Modified:
   core/trunk/src/main/java/org/jboss/cache/util/FastCopyHashMap.java
Log:
Optimize initial sizing by factoring in the load factor

Modified: core/trunk/src/main/java/org/jboss/cache/util/FastCopyHashMap.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/util/FastCopyHashMap.java	2009-01-05 17:48:27 UTC (rev 7379)
+++ core/trunk/src/main/java/org/jboss/cache/util/FastCopyHashMap.java	2009-01-05 17:54:59 UTC (rev 7380)
@@ -134,10 +134,16 @@
    {
       int c = 1;
       for (; c < initialCapacity; c <<= 1) ;
+      threshold = (int) (c * loadFactor);
 
+      // Include the load factor when sizing the table for the first time
+      if (initialCapacity > threshold && c < MAXIMUM_CAPACITY)
+      {
+         c <<= 1;
+         threshold = (int) (c * loadFactor);
+      }
+
       this.table = (Entry<K, V>[]) new Entry[c];
-
-      threshold = (int) (c * loadFactor);
    }
 
    public FastCopyHashMap(int initialCapacity)




More information about the jbosscache-commits mailing list