On Fri, 2 May 2025 17:24:06 GMT, Roger Riggs <rri...@openjdk.org> wrote:
>> Refactor AbstractStringBuilder to maintain consistency among count, coder, >> and value buffers while the buffer capacity is being expanded and/or >> inflated from Latin1 to UTF16 representations. >> The refactoring pattern is to read and write AbstractStringBuilder fields >> once using locals for all intermediate values. >> Support methods are static, designed to pass all values as arguments and >> return a value. >> >> The value byte array is reallocated under 3 conditions: >> - Increasing the capacity with the same encoder >> - Increasing the capacity and inflation to change the coder from LATIN1 to >> UTF16 >> - Inflation with the same capacity >> >> Added StressSBTest to exercise public instance methods of StringBuilder. > > Roger Riggs has updated the pull request incrementally with one additional > commit since the last revision: > > Optimize StringUTF16.putCharsAt a bit. > Fixup hotspot Helper of putCharsAt to remove return value to match > StringUTF16.putCharsAt. src/java.base/share/classes/java/lang/AbstractStringBuilder.java line 1970: > 1968: private static byte[] appendChars(byte[] value, byte coder, int > count, char[] s, int off, int end) { > 1969: if (isLatin1(coder)) { > 1970: for (int i = off, j = count; i < end; i++) { Suggestion: int compressed = StringUTF16.compress(s, off, value, count, end - off); for (int i = compressed + off, j = count + compressed; i < end; i++) { Refer to PR #24773, adding StringUTF16.compress preprocessing here will improve the performance of java.io.BufferedReader::readLine method. Should it be done at once or separately for PR #24773 to make changes? ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/24967#discussion_r2071954862