On Wed, 25 Jun 2025 02:01:18 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 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 incrementally with one additional > commit since the last revision: > > Microbenchmark java.lang.StringBuilders is modified to not re-use existing > StringBuilders, from @RogerRiggs src/java.base/share/classes/java/lang/StringUTF16.java line 1490: > 1488: val, > 1489: Unsafe.ARRAY_BYTE_BASE_OFFSET + ((long) index << 1), > 1490: ((long) (end - off)) << 1); Either: Suggestion: (long) (end - off) << 1); Or add parentheses around `(long) index` and `(long) off` that's the operand to `<< 1`. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/24773#discussion_r2169526168