On Mon, 2 Aug 2021 11:34:00 GMT, Сергей Цыпанов
<[email protected]> wrote:
>> `AbstractStringBuilder.charAt(int)` does bounds check before calling
>> `charAt()` (for non-latin Strings):
>>
>> @Override
>> public char charAt(int index) {
>> checkIndex(index, count);
>> if (isLatin1()) {
>> return (char)(value[index] & 0xff);
>> }
>> return StringUTF16.charAt(value, index);
>> }
>>
>> This can be improved by removing bounds check from ASB.charAt() in favour of
>> one in String*.charAt(). This gives slight improvement:
>>
>> before
>> Benchmark Mode Cnt Score Error Units
>> StringBuilderCharAtBenchmark.latin avgt 50 2,827 ± 0,024 ns/op
>> StringBuilderCharAtBenchmark.utf avgt 50 2,985 ± 0,020 ns/op
>>
>> after
>> Benchmark Mode Cnt Score Error Units
>> StringBuilderCharAtBenchmark.latin avgt 50 2,434 ± 0,004 ns/op
>> StringBuilderCharAtBenchmark.utf avgt 50 2,631 ± 0,004 ns/op
>
> Сергей Цыпанов has updated the pull request incrementally with one additional
> commit since the last revision:
>
> 8270160 Revert irrelevant changes
Marked as reviewed by redestad (Reviewer).
-------------
PR: https://git.openjdk.java.net/jdk/pull/4738