On Fri, 27 Nov 2020 20:28:17 GMT, Сергей Цыпанов 
<github.com+10835776+stsypa...@openjdk.org> wrote:

>> src/java.base/share/classes/java/lang/AbstractStringBuilder.java line 1721:
>> 
>>> 1719:             return;
>>> 1720:         }
>>> 1721:         inflate();
>> 
>> Like in `String.getBytes(byte[], int, byte)` I think we could do an 
>> `arraycopy` if both are `false` too, just need to carefully adjust the 
>> `index` et.c. In fact the only case that can't use an `arraycopy` in the end 
>> is when `s.isLatin1()` and the current sb is already inflated (that's what 
>> the `StringLatin1.inflate` branch does in `getBytes`). 
>> 
>> I think if you consolidate/merge this with the logic in 
>> `String.getBytes(byte[], int, byte)` as suggested you'll end up with a 
>> sizeable improvement on non-latin1 cases too.
>
> Done

Nice! 

Did this help the non-latin1 case in your microbenchmark?

-------------

PR: https://git.openjdk.java.net/jdk/pull/402

Reply via email to