RFR: 8355177: Speed up StringBuilder::append(char[]) via Unsafe::copyMemory [v6]
Shaojin Wen
swen at openjdk.org
Wed Jun 25 01:48:43 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 Unsafe.copyMemory instead of the character copy of the char-by-char loop to improve the speed.
>
> @RogerRiggs completed the optimization when the encoder is LATIN1 in PR #24967. This PR continues to complete the optimization when the encoder is UTF16.
Shaojin Wen has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 12 commits:
- inline checkBoundsBeginEnd, from @RogerRiggs
- inline putCharsUnchecked, from @RogerRiggs
- Merge remote-tracking branch 'upstream/master' into optim_sb_append_chars_202504
- copyright
- 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/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[])
- ... and 2 more: https://git.openjdk.org/jdk/compare/50910576...2a45cfc1
-------------
Changes: https://git.openjdk.org/jdk/pull/24773/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=24773&range=05
Stats: 42 lines in 2 files changed: 34 ins; 6 del; 2 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