8282429: StringBuilder/StringBuffer.toString() skip compressing for UTF16 strings

Reviewed-by: djelinski, redestad
This commit is contained in:
Xin Liu 2022-04-01 04:42:03 +00:00
parent 8eff80682a
commit bab431cc12
6 changed files with 122 additions and 11 deletions

View file

@ -450,8 +450,7 @@ public final class StringBuilder
@IntrinsicCandidate
public String toString() {
// Create a copy, don't share the array
return isLatin1() ? StringLatin1.newString(value, 0, count)
: StringUTF16.newString(value, 0, count);
return new String(this);
}
/**