src/share/classes/java/util/concurrent/ConcurrentHashMap.java

Print this page
rev 5440 : 7173919: Minor optimization of hashing methods
Summary: several minor optimizations to hashing methods used by hash map classes
Reviewed-by: duke

@@ -267,17 +267,15 @@
      * because ConcurrentHashMap uses power-of-two length hash tables,
      * that otherwise encounter collisions for hashCodes that do not
      * differ in lower or upper bits.
      */
     private int hash(Object k) {
-       int h = hashSeed;
-
         if (k instanceof String) {
             return ((String) k).hash32();
         }
 
-        h ^= k.hashCode();
+        int h = hashSeed ^ k.hashCode();
 
         // Spread bits to regularize both segment and index locations,
         // using variant of single-word Wang/Jenkins hash.
         h += (h <<  15) ^ 0xffffcd7d;
         h ^= (h >>> 10);