RFR: 8306374: (bf) Improve performance of DirectCharBuffer::append(CharSequence[,int,int]) [v4]
Brian Burkhalter
bpb at openjdk.org
Tue Apr 25 23:17:49 UTC 2023
On Sat, 22 Apr 2023 14:48:15 GMT, ExE Boss <duke at openjdk.org> wrote:
>> src/java.base/share/classes/java/nio/Direct-X-Buffer.java.template line 452:
>>
>>> 450:
>>> 451: private $Type$Buffer appendChars(CharSequence csq, int start, int end) {
>>> 452: checkSession();
>>
>> This template is for direct buffers so I'm not 100% sure that checkSession is needed here. If the session is closed then SMA.copyMemory used in putArray will throw.
>
> This is probably to avoid allocating the temporary `char[] buf` array when the session is known to be closed.
The primary direct buffer constructor is
// Primary constructor
//
Direct$Type$Buffer$RW$(int cap) { // package-private
so in general the `segment` will be `null` and checking it provides no value.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13522#discussion_r1177150138
More information about the nio-dev
mailing list