8273100: Improve AbstractStringBuilder.append(String) when using CompactStrings
Reviewed-by: rriggs, alanb
This commit is contained in:
parent
9732fbe428
commit
98fa53357a
@ -603,9 +603,7 @@ abstract class AbstractStringBuilder implements Appendable, CharSequence {
|
|||||||
}
|
}
|
||||||
int len = asb.length();
|
int len = asb.length();
|
||||||
ensureCapacityInternal(count + len);
|
ensureCapacityInternal(count + len);
|
||||||
if (getCoder() != asb.getCoder()) {
|
inflateIfNeededFor(asb);
|
||||||
inflate();
|
|
||||||
}
|
|
||||||
asb.getBytes(value, count, coder);
|
asb.getBytes(value, count, coder);
|
||||||
count += len;
|
count += len;
|
||||||
return this;
|
return this;
|
||||||
@ -1712,15 +1710,26 @@ abstract class AbstractStringBuilder implements Appendable, CharSequence {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void putStringAt(int index, String str, int off, int end) {
|
private void inflateIfNeededFor(String input) {
|
||||||
if (getCoder() != str.coder()) {
|
if (COMPACT_STRINGS && (coder != input.coder())) {
|
||||||
inflate();
|
inflate();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void inflateIfNeededFor(AbstractStringBuilder input) {
|
||||||
|
if (COMPACT_STRINGS && (coder != input.getCoder())) {
|
||||||
|
inflate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void putStringAt(int index, String str, int off, int end) {
|
||||||
|
inflateIfNeededFor(str);
|
||||||
str.getBytes(value, off, index, coder, end - off);
|
str.getBytes(value, off, index, coder, end - off);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void putStringAt(int index, String str) {
|
private void putStringAt(int index, String str) {
|
||||||
putStringAt(index, str, 0, str.length());
|
inflateIfNeededFor(str);
|
||||||
|
str.getBytes(value, index, coder);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final void appendChars(char[] s, int off, int end) {
|
private final void appendChars(char[] s, int off, int end) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user