From 47013361b4c85dea2589bbfe8ffa77598c82742c Mon Sep 17 00:00:00 2001 From: Goktug Gokdogan Date: Thu, 27 Jul 2023 19:33:05 -0700 Subject: [PATCH] Remove leftover int overflow workaround. PiperOrigin-RevId: 551709387 --- jre/java/java/util/BitSet.java | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/jre/java/java/util/BitSet.java b/jre/java/java/util/BitSet.java index fcc449727e..d0d73cc130 100644 --- a/jre/java/java/util/BitSet.java +++ b/jre/java/java/util/BitSet.java @@ -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) { @@ -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;