Skip to content

Commit

Permalink
Remove leftover int overflow workaround.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 551709387
  • Loading branch information
gkdn authored and copybara-github committed Jul 28, 2023
1 parent 11d7414 commit 4701336
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions jre/java/java/util/BitSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,6 @@ private static int wordAt(int[] array, int index) {
return array[index] | 0; // ensure int even if we go out of bounds.
}

// GWT emulates integer with double and doesn't overflow. Enfore it by a integer mask.
private static int enforceOverflow(int value) {
return value & 0xffffffff;
}

public void and(BitSet set) {
// a & a is just a.
if (this == set) {
Expand Down Expand Up @@ -520,11 +515,11 @@ public int hashCode() {

for (int i = 0; i <= lastIndex; i++) {
int value = wordAt(array, i);
// Hash one byte at a time using FNV1 and make sure we don't overflow 32 bit int.
hash = enforceOverflow(hash * fnvPrime) ^ (value & 0xff);
hash = enforceOverflow(hash * fnvPrime) ^ ((value >>> 8) & 0xff);
hash = enforceOverflow(hash * fnvPrime) ^ ((value >>> 16) & 0xff);
hash = enforceOverflow(hash * fnvPrime) ^ (value >>> 24);
// Hash one byte at a time using FNV1.
hash = (hash * fnvPrime) ^ (value & 0xff);
hash = (hash * fnvPrime) ^ ((value >>> 8) & 0xff);
hash = (hash * fnvPrime) ^ ((value >>> 16) & 0xff);
hash = (hash * fnvPrime) ^ (value >>> 24);
}

return hash;
Expand Down

0 comments on commit 4701336

Please sign in to comment.