RFR: 8355177: Speed up StringBuilder::append(char[]) via UTF16::compress & Unsafe::copyMemory [v4]
Shaojin Wen
swen at openjdk.org
Fri May 2 03:49:39 UTC 2025
> 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
-------------
Changes: https://git.openjdk.org/jdk/pull/24773/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=24773&range=03
Stats: 46 lines in 3 files changed: 40 ins; 0 del; 6 mod
Patch: https://git.openjdk.org/jdk/pull/24773.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/24773/head:pull/24773
PR: https://git.openjdk.org/jdk/pull/24773
More information about the core-libs-dev
mailing list