On Jun 14 2012, at 09:29 , Ulf Zibis wrote: > Hi Mike, > > I like the 1-liner ... :-) > int h = hashSeed ^ k.hashCode(); > > ... but I'm still missing a little comment, what this xor with a hashSeed > serves for. Such as brief, as the next following 3 lines about preventing > from collisions.
The hashSeed randomizes table order to reduce the value of partial collisions--only full collisions will predictably collide. The comment I think you are looking for is on hashSeed itself. /** * A randomizing value associated with this instance that is applied to * hash code of keys to make hash collisions harder to find. */ > > WeakHashMap.hash(Object) could be private too, instead final. OK. I will probably make it private method though I hate opening an issue just for one keyword. > > And last... you have reinserted/left the space after the cast in some > occurences. ;-) Netbeans did actually. I don't do my own source formatting. Mike > > -Ulf > > Am 14.06.2012 17:27, schrieb mike.dui...@oracle.com: >> Changeset: 505455116320 >> Author: mduigou >> Date: 2012-06-13 16:48 -0700 >> URL: http://hg.openjdk.java.net/jdk8/tl/jdk/rev/505455116320 >> >> 7173919: Minor optimization of hashing methods >> Summary: several minor optimizations to hashing methods used by hash map >> classes >> Reviewed-by: dholmes >> >> ! src/share/classes/java/util/HashMap.java >> ! src/share/classes/java/util/Hashtable.java >> ! src/share/classes/java/util/WeakHashMap.java >> ! src/share/classes/java/util/concurrent/ConcurrentHashMap.java >> >> > >