hg: jdk8/tl/jdk: 7173919: Minor optimization of hashing methods
Ulf Zibis
Ulf.Zibis at gmx.de
Thu Jun 14 20:51:34 UTC 2012
Am 14.06.2012 22:26, schrieb Mike Duigou:
> 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.
> */
Oops, sorry, I oversaw that. I'm ok with.
Anyway, I still don't understand the trick behind. Is there a good explanation in the web?
>> 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.
8-)
If there is no performance impact, it could stay as it is from my side, I was just wondering about
the inconsistency.
>> 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.
Wasn't you one of those, who argued against the space some days ago?
But it's easy to adapt it in Netbeans forever:
Tools->Options->Editor->Formatting->Java->Spaces->Other->After Type Cast
-Ulf
More information about the core-libs-dev
mailing list