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

@ -712,9 +712,7 @@ import jdk.internal.vm.annotation.IntrinsicCandidate;
@IntrinsicCandidate
public synchronized String toString() {
if (toStringCache == null) {
return toStringCache =
isLatin1() ? StringLatin1.newString(value, 0, count)
: StringUTF16.newString(value, 0, count);
return toStringCache = new String(this, null);
}
return new String(toStringCache);
}