RFR: 8305811: (bf) Improve performance of CharBuffer::append(CharSequence[,int,int]) [v8]

Alan Bateman alanb at openjdk.org
Sat Apr 15 08:18:35 UTC 2023


On Fri, 14 Apr 2023 16:56:46 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:

>> Use the `getChars` method of `String`, `StringBuffer`, and `StringBuilder` to load the chars directly into the array of the heap buffer.
>
> Brian Burkhalter has updated the pull request incrementally with one additional commit since the last revision:
> 
>   8305811: Remove fallback to append(CS) when start == 0 and end == csq.length() (caused failure in Appendable/Basic.java)

src/java.base/share/classes/java/nio/Heap-X-Buffer.java.template line 315:

> 313: #if[rw]
> 314:         if (csq instanceof StringBuilder)
> 315:             return appendChars(csq, 0, csq.length());

No special casing of String here as append(String) as the implementation in the base class uses put(String) so nothing to be gained.

No special casing of StringBuffer as it is legacy/not-interesting. Also it's caching of the String value means you don't see the difference in micros, is that right?

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/13415#discussion_r1167433536


More information about the nio-dev mailing list