Avoid using ensureInt for out of bounds array access
J2CL handles integer overflow correctly so doesn't need ensureInt
otherwise. This will enable J2CL to make Coercions.ensureInt no-op.
PiperOrigin-RevId: 339986208
Change-Id: I9aebc4bc54702fbb7485f1dc0340d66b53d8a534
diff --git a/user/super/com/google/gwt/emul/java/util/BitSet.java b/user/super/com/google/gwt/emul/java/util/BitSet.java
index 417850d..56d0e77 100644
--- a/user/super/com/google/gwt/emul/java/util/BitSet.java
+++ b/user/super/com/google/gwt/emul/java/util/BitSet.java
@@ -16,7 +16,6 @@
package java.util;
-import static javaemul.internal.Coercions.ensureInt;
import static javaemul.internal.InternalPreconditions.checkArraySize;
import javaemul.internal.ArrayHelper;
@@ -222,7 +221,7 @@
}
private static int wordAt(int[] array, int index) {
- return ensureInt(array[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.