Details
-
Improvement
-
Resolution: Won't Fix
-
Minor - P4
-
None
-
None
-
None
-
None
Description
Object ids are used in maps and sets all over the place. It makes sense to cache the hash computation in a similar manor as the String.hashCode() method.
From String.java
public int hashCode() {
|
int h = hash;
|
int len = count;
|
if (h == 0 && len > 0) {
|
int off = offset;
|
char val[] = value;
|
|
|
for (int i = 0; i < len; i++) {
|
h = 31*h + val[off++];
|
}
|
hash = h;
|
}
|
return h;
|
}
|