8058643: (str) Re-examine hashCode implementation
Reviewed-by: martin, alanb, sherman, redestad
This commit is contained in:
parent
f07521a354
commit
e3bda3bd0a
@ -1451,11 +1451,9 @@ public final class String
|
|||||||
*/
|
*/
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
int h = hash;
|
int h = hash;
|
||||||
if (h == 0 && value.length > 0) {
|
if (h == 0) {
|
||||||
char val[] = value;
|
for (char v : value) {
|
||||||
|
h = 31 * h + v;
|
||||||
for (int i = 0; i < value.length; i++) {
|
|
||||||
h = 31 * h + val[i];
|
|
||||||
}
|
}
|
||||||
hash = h;
|
hash = h;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user