RFR: 8299982: (bf) Buffer.checkIndex(int, int) should use Objects.checkIndex(int, int) [v2]
Alan Bateman
alanb at openjdk.org
Wed Jan 25 20:26:18 UTC 2023
On Wed, 25 Jan 2023 20:22:19 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:
>> Replace explicit check of indexes in `Buffer::checkIndex(int,int)` with a call to `Objects::checkIndex(int,int)` in order to improve the throughput of other methods which invoke `Buffer::checkIndex(int,int)`.
>
> Brian Burkhalter has updated the pull request incrementally with one additional commit since the last revision:
>
> 8299982: Change Objects::checkIndex to Preconditions::checkIndex; improve exception message
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.
-------------
PR: https://git.openjdk.org/jdk/pull/12174
More information about the nio-dev
mailing list