RFR: 8310929: Optimization for Integer.toString [v10]
温绍锦
duke at openjdk.org
Sun Jul 2 02:16:10 UTC 2023
On Sun, 2 Jul 2023 02:05:48 GMT, Chen Liang <liach at openjdk.org> wrote:
>> 温绍锦 has updated the pull request incrementally with one additional commit since the last revision:
>>
>> use upper case for static final field
>
> src/java.base/share/classes/java/lang/StringUTF16.java line 1540:
>
>> 1538: if (isBigEndian()) {
>> 1539: for (int i = 0; i < digits.length; i++) {
>> 1540: digits[i] <<= 8;
>
> I know this changes the char-based endian (so putInt puts the non-0 to right bytes), what I suggest is something like:
>
> digits[i] = Integer.reverseBytes(digits[i] << 8);
>
>
> And you then remove the trailing `false` (little-endian) argument to `UNSAFE.putIntUnaligned`.
>
> This is safe because you don't use `PACKED_DIGITS_UTF16` with bitwise operations, unlike in UUID.
in the getChars method, it is written from the back to the front. I run benchmark and found that the performance of using little endian is better.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/14699#discussion_r1249100341
More information about the core-libs-dev
mailing list