On Mon, 5 May 2025 17:32:19 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: > > Refactor to consistently use `isLatin1(coder)` within AbstractStringBuilder. src/java.base/share/classes/java/lang/AbstractStringBuilder.java line 185: > 183: if (coder == another.coder) { > 184: return isLatin1(coder) ? StringLatin1.compareTo(val1, val2, > count1, count2) > 185: : StringUTF16.compareTo(val1, val2, > count1, count2); Suggestion: return isLatin1(coder) ? StringLatin1.compareTo(val1, val2, count1, count2) : StringUTF16.compareTo(val1, val2, count1, count2); As before, align the code src/java.base/share/classes/java/lang/AbstractStringBuilder.java line 188: > 186: } > 187: return isLatin1(coder) ? StringLatin1.compareToUTF16(val1, val2, > count1, count2) > 188: : StringUTF16.compareToLatin1(val1, val2, > count1, count2); Suggestion: return isLatin1(coder) ? StringLatin1.compareToUTF16(val1, val2, count1, count2) : StringUTF16.compareToLatin1(val1, val2, count1, count2); As before, align the code ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/24967#discussion_r2074477815 PR Review Comment: https://git.openjdk.org/jdk/pull/24967#discussion_r2074478089