Skip to content

Commit 23bd6b5

Browse files
Aleksei VoitylovRealCLanger
authored andcommitted
8359454: Enhance String handling
Reviewed-by: abakhtin, fferrari Backport-of: 2f2665738a67aeed224b54870608a346eb627d2a
1 parent bb9edcc commit 23bd6b5

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

src/java.base/share/classes/java/lang/AbstractStringBuilder.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1313,8 +1313,8 @@ public AbstractStringBuilder insert(int dstOffset, CharSequence s,
13131313
ensureCapacityInternal(count + len);
13141314
shift(dstOffset, len);
13151315
count += len;
1316-
if (s instanceof String) {
1317-
putStringAt(dstOffset, (String) s, start, end);
1316+
if (s instanceof String str && str.length() == len) {
1317+
putStringAt(dstOffset, str);
13181318
} else {
13191319
putCharsAt(dstOffset, s, start, end);
13201320
}
@@ -1741,11 +1741,6 @@ private void inflateIfNeededFor(AbstractStringBuilder input) {
17411741
}
17421742
}
17431743

1744-
private void putStringAt(int index, String str, int off, int end) {
1745-
inflateIfNeededFor(str);
1746-
str.getBytes(value, off, index, coder, end - off);
1747-
}
1748-
17491744
private void putStringAt(int index, String str) {
17501745
inflateIfNeededFor(str);
17511746
str.getBytes(value, index, coder);

0 commit comments

Comments
 (0)