RFR: 8305811: (bf) Improve performance of CharBuffer::append(CharSequence[,int,int]) [v5]
Brian Burkhalter
bpb at openjdk.org
Fri Apr 14 15:35:40 UTC 2023
On Fri, 14 Apr 2023 06:53:34 GMT, Alan Bateman <alanb at openjdk.org> wrote:
>> Brian Burkhalter has updated the pull request incrementally with one additional commit since the last revision:
>>
>> 8305811: Use getChars() when appending a full String or StringBuffer
>
> src/java.base/share/classes/java/nio/Heap-X-Buffer.java.template line 305:
>
>> 303: } else if (csq instanceof StringBuffer buf) {
>> 304: buf.getChars(start, end, hb, ix(pos));
>> 305: }
>
> Surprised to see legacy StringBuffer here but okay. A small suggestion is to keep check for String first, and keep the naming from the previous iteration, i.e.
>
>
> if (csq instanceof String str) {
> str.getChars(start, end, hb, ix(pos));
> } else if (csq instanceof StringBuilder sb) {
> sb.getChars(start, end, hb, ix(pos));
> } else if (csq instanceof StringBuffer sb) {
> sb.getChars(start, end, hb, ix(pos));
> }
I put `StringBuilder` first as it is always used for the `append` without `start` and `end` and sometimes for the version without but I've no problem changing it.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13415#discussion_r1166985498
More information about the nio-dev
mailing list