RFR: 8306374: (bf) Improve performance of DirectCharBuffer::append(CharSequence[,int,int]) [v2]
Chen Liang
liach at openjdk.org
Wed Apr 19 16:37:46 UTC 2023
On Wed, 19 Apr 2023 16:25:54 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:
>> Use `getChars()` to copy characters to an intermediate local `char[]` array and then `putArray()` to copy the chars into the buffer itself.
>
> Brian Burkhalter has updated the pull request incrementally with one additional commit since the last revision:
>
> 8306374: Add explicit bounds check; allocate less memory if possible
src/java.base/share/classes/java/nio/Direct-X-Buffer.java.template line 456:
> 454: int length = end - start;
> 455: Objects.checkFromIndexSize(start, length,
> 456: csq == null ? 0 : csq.length());
Suggestion:
Objects.checkFromIndexSize(start, length, csq.length());
Aren't the calls to `appendChars` already guarded by `instanceof` checks, which produces `false` for `null`?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13522#discussion_r1171593510
More information about the nio-dev
mailing list