MCPcopy Create free account
hub / github.com/antlr/codebuff / rehash

Method rehash

output/java_guava/1.4.19/LocalCache.java:1867–1877  ·  view source on GitHub ↗

Applies a supplemental hash function to a given hash code, which defends against poor quality hash functions. This is critical when the concurrent hash map uses power-of-two length hash tables, that otherwise encounter collisions for hash codes that do not differ in lower or upper bits. @param h ha

(int h)

Source from the content-addressed store, hash-verified

1865 */
1866
1867 static int rehash(int h) {
1868 // Spread bits to regularize both segment and index locations,
1869 // using variant of single-word Wang/Jenkins hash.
1870 // TODO(kevinb): use Hashing/move this to Hashing?
1871 h += (h << 15) ^ 0xffffcd7d;
1872 h ^= (h >>> 10);
1873 h += (h << 3);
1874 h ^= (h >>> 6);
1875 h += (h << 2) + (h << 14);
1876 return h ^ (h >>> 16);
1877 }
1878
1879 /**
1880 * This method is a convenience for testing. Code should call {@link Segment#newEntry} directly.

Callers 1

hashMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected