RFR: 8351443: Improve robustness of StringBuilder [v3]

Roger Riggs rriggs at openjdk.org
Mon May 5 18:22:47 UTC 2025


On Fri, 2 May 2025 17:49:20 GMT, Shaojin Wen <swen at openjdk.org> wrote:

>> Roger Riggs has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Optimize StringUTF16.putCharsAt a bit.
>>   Fixup hotspot Helper of putCharsAt to remove return value to match StringUTF16.putCharsAt.
>
> src/java.base/share/classes/java/lang/AbstractStringBuilder.java line 1970:
> 
>> 1968:     private static byte[] appendChars(byte[] value, byte coder, int count, char[] s, int off, int end) {
>> 1969:         if (isLatin1(coder)) {
>> 1970:             for (int i = off, j = count; i < end; i++) {
> 
> Suggestion:
> 
>             int compressed = StringUTF16.compress(s, off, value, count, end - off);
>             for (int i = compressed + off, j = count + compressed; i < end; i++) {
> 
> Refer to PR #24773, adding StringUTF16.compress preprocessing here will improve the performance of java.io.BufferedReader::readLine method.
> 
> Should it be done at once or separately for PR #24773 to make changes?

I rolled this suggestion into ff3d841; and fixed a second occurence.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/24967#discussion_r2073947019


More information about the core-libs-dev mailing list