RFR: 8355177: Speed up StringBuilder::append(char[]) via UTF16::compress & Unsafe::copyMemory [v2]

Shaojin Wen swen at openjdk.org
Mon Apr 21 15:51:58 UTC 2025


On Mon, 21 Apr 2025 15:25:34 GMT, Chen Liang <liach at openjdk.org> wrote:

>> Shaojin Wen has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   putCharsUnchecked
>
> src/java.base/share/classes/java/lang/AbstractStringBuilder.java line 1773:
> 
>> 1771:             int compressed = StringUTF16.compress(s, off, val, count, end - off);
>> 1772:             count += compressed;
>> 1773:             off += compressed;
> 
> Should we update `this.count` eagerly after compression?

In the StringLatin1.canEncode(c) branch of the original code, this.count is not updated either, and the behavior is the same as before.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/24773#discussion_r2052637495


More information about the core-libs-dev mailing list