8359454: Enhance String handling

This commit is contained in:
Aleksei Voitylov
2025-09-15 10:49:36 +02:00
committed by Vitaly Provodin
parent d299d9375b
commit ee4670845c

View File

@@ -1313,8 +1313,8 @@ abstract sealed class AbstractStringBuilder implements Appendable, CharSequence
ensureCapacityInternal(count + len);
shift(dstOffset, len);
count += len;
if (s instanceof String) {
putStringAt(dstOffset, (String) s, start, end);
if (s instanceof String str && str.length() == len) {
putStringAt(dstOffset, str);
} else {
putCharsAt(dstOffset, s, start, end);
}
@@ -1741,11 +1741,6 @@ abstract sealed class AbstractStringBuilder implements Appendable, CharSequence
}
}
private void putStringAt(int index, String str, int off, int end) {
inflateIfNeededFor(str);
str.getBytes(value, off, index, coder, end - off);
}
private void putStringAt(int index, String str) {
inflateIfNeededFor(str);
str.getBytes(value, index, coder);