RFR: 8299982: (bf) Buffer.checkIndex(int, int) should use Preconditions.checkIndex(int, int, BiFunction) [v2]
Alan Bateman
alanb at openjdk.org
Thu Jan 26 07:20:49 UTC 2023
On Wed, 25 Jan 2023 20:30:55 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:
>> src/java.base/share/classes/java/nio/Buffer.java line 752:
>>
>>> 750: final int checkIndex(int i, int nb) { // package-private
>>> 751: return Preconditions.checkIndex(i, limit - nb + 1,
>>> 752: (x, y) -> {
>>
>> I don't know if you've retested the performance but I think you'll need this parameter to be a constant and checkIndex may need to be ForceInline. While we're here, I think we'll have to check the exception message throw by the 1-arg checkIndex to make sure it make sense for buffers.
>
> I re-tested with and without ForceInline and see little difference.
I was hoping the 3rd parameter to Preconditions.checkIndex would be constant. It looks like it's a capturing lambda ("this" is captured because of the access to the position/limit fields). Hmm, maybe start out simple with a constant, otherwise this change is going to require much wider startup and performance testing.
-------------
PR: https://git.openjdk.org/jdk/pull/12174
More information about the nio-dev
mailing list