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

@ -4521,7 +4521,8 @@ public final class String
this.coder = LATIN1;
this.value = Arrays.copyOfRange(val, 0, length);
} else {
if (COMPACT_STRINGS) {
// only try to compress val if some characters were deleted.
if (COMPACT_STRINGS && asb.maybeLatin1) {
byte[] buf = StringUTF16.compress(val, 0, length);
if (buf != null) {
this.coder = LATIN1;