On Fri, 2 May 2025 03:49:39 GMT, Shaojin Wen <s...@openjdk.org> wrote:
>> In BufferedReader.readLine and other similar scenarios, we need to use >> StringBuilder.append(char[]) to build the string. >> >> For these scenarios, we can use the intrinsic method StringUTF16.compress >> and Unsafe.copyMemory instead of the character copy of the char-by-char loop >> to improve the speed. > > Shaojin Wen has updated the pull request with a new target base due to a > merge or a rebase. The pull request now contains seven commits: > > - Merge remote-tracking branch 'upstream/master' into > optim_sb_append_chars_202504 > > # Conflicts: > # src/java.base/share/classes/java/lang/AbstractStringBuilder.java > - Merge remote-tracking branch 'upstream/master' into > optim_sb_append_chars_202504 > > # Conflicts: > # src/java.base/share/classes/java/lang/StringUTF16.java > - putCharsUnchecked > - copyright > - Using StringUTF16.compress to speed up LATIN1 StringBuilder append(char[]) > - Using Unsafe.copyMemory to speed up UTF16 StringBuilder append(char[]) > - add append(char[]) benchmark > ```java > > char[] ca = new char[end - off]; > ``` > > Your code here has a memory allocation, which may cause slowdown This is exactly what I wanted to express with my posting. ------------- PR Comment: https://git.openjdk.org/jdk/pull/24773#issuecomment-2846485487