Integrated: 8355177: Speed up StringBuilder::append(char[]) via Unsafe::copyMemory

Shaojin Wen swen at openjdk.org
Wed Jul 30 13:19:04 UTC 2025


On Mon, 21 Apr 2025 07:00:36 GMT, Shaojin Wen <swen at 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 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.

This pull request has now been integrated.

Changeset: e2feff85
Author:    Shaojin Wen <swen at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/e2feff85995cf2d0b8ecc2262cf4e74b74de3e31
Stats:     40 lines in 2 files changed: 32 ins; 6 del; 2 mod

8355177: Speed up StringBuilder::append(char[]) via Unsafe::copyMemory

Reviewed-by: rriggs, rgiulietti

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

PR: https://git.openjdk.org/jdk/pull/24773


More information about the core-libs-dev mailing list