RFR 8135248: Add utility methods to check indexes and ranges
Jeff Hain
jeffhain at rocketmail.com
Mon Sep 21 18:12:05 UTC 2015
Hi.
In your webrev:
+ if ((length | fromIndex | size) < 0 || size > length - fromIndex)
+ throw outOfBounds(fromIndex, size, length, oobe);
In Buffer.java (equivalent if adding "| size"):
static void checkBounds(int off, int len, int size) { // package-private
if ((off | len | (off + len) | (size - (off + len))) < 0)
throw new IndexOutOfBoundsException();
}
Maybe the second way (only one boolean check) is better for perfs?
-Jeff
More information about the core-libs-dev
mailing list