hg: jdk8/tl/jdk: 7173919: Minor optimization of hashing methods
mike.duigou at oracle.com
Thu Jun 14 20:26:40 UTC 2012
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.
> Am 14.06.2012 17:27, schrieb mike.duigou at 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
More information about the core-libs-dev