150 |
|
* defends against poor quality hash functions. This is critical |
151 |
|
* because ConcurrentHashMap uses power-of-two length hash tables, |
152 |
|
* that otherwise encounter collisions for hashCodes that do not |
153 |
< |
* differ in lower bits. |
153 |
> |
* differ in lower or upper bits. |
154 |
|
*/ |
155 |
|
private static int hash(int h) { |
156 |
|
// Spread bits to regularize both segment and index locations, |
157 |
< |
// using variant of Jenkins's shift-based hash. |
158 |
< |
h += ~(h << 13); |
159 |
< |
h ^= h >>> 7; |
160 |
< |
h += h << 3; |
161 |
< |
h ^= h >>> 17; |
162 |
< |
h += h << 5; |
163 |
< |
return h; |
157 |
> |
// using variant of single-word Wang/Jenkins hash. |
158 |
> |
h += (h << 15) ^ 0xffffcd7d; |
159 |
> |
h ^= (h >>> 10); |
160 |
> |
h += (h << 3); |
161 |
> |
h ^= (h >>> 6); |
162 |
> |
h += (h << 2) + (h << 14); |
163 |
> |
return h ^ (h >>> 16); |
164 |
|
} |
165 |
|
|
166 |
|
/** |