RFR: 8359424: Eliminate table lookup in Integer/Long toHexString [v7]
Chen Liang
liach at openjdk.org
Fri Jan 23 02:28:09 UTC 2026
On Fri, 23 Jan 2026 01:30:31 GMT, Shaojin Wen <swen at openjdk.org> wrote:
>> In PR #22928, UUID introduced long-based vectorized hexadecimal to string conversion, which can also be used in Integer::toHexString and Long::toHexString to eliminate table lookups. The benefit of eliminating table lookups is that the performance is better when cache misses occur.
>
> Shaojin Wen has updated the pull request incrementally with one additional commit since the last revision:
>
> from liach
src/java.base/share/classes/java/lang/Long.java line 313:
> 311: int mag = Long.SIZE - Long.numberOfLeadingZeros(i);
> 312: int len = Math.max(((mag + 3) >> 2), 1);
> 313: long x = HexDigits.hex8Be((int)i);
Suggestion:
long x = HexDigits.hex8Be((int) i);
src/java.base/share/classes/java/lang/Long.java line 319:
> 317: len -= 8;
> 318: Unsafe.getUnsafe().putLongUnaligned(chars, Unsafe.ARRAY_BYTE_BASE_OFFSET + len, x, true);
> 319: x = HexDigits.hex8Be((int)(i >>> 32));
Suggestion:
x = HexDigits.hex8Be((int) (i >>> 32));
Similar indents elsewhere.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/22942#discussion_r2719343056
PR Review Comment: https://git.openjdk.org/jdk/pull/22942#discussion_r2719343405
More information about the core-libs-dev
mailing list