On Wed, 21 Jun 2023 10:11:09 GMT, 温绍锦 <d...@openjdk.org> wrote:

>> By optimizing the implementation of java.lang.Long#fastUUID, the performance 
>> of the java.util.UUID#toString method can be significantly improved.
>> 
>> The following are the test results of JMH: 
>> 
>> Benchmark                     Mode  Cnt      Score      Error   Units
>> UUIDUtilsBenchmark.new       thrpt    5  92676.550 ±  292.213  ops/ms
>> UUIDUtilsBenchmark.original  thrpt    5  37040.165 ± 1023.532  ops/ms
>
> 温绍锦 has updated the pull request incrementally with one additional commit 
> since the last revision:
> 
>   8310502 : HEX256 initialization use constant values improved jvm startup

src/java.base/share/classes/java/lang/Long.java line 128:

> 126:         26209, 26210, 26211, 26212, 26213, 26214
> 127:     };
> 128: 

Can we perhaps have hex literals here? I think they are easier to visually 
check than decimals.

static final char[] HEX256 = new char[]{
        0x3030, 0x3031, 0x3032, 0x3033, 0x3034, 0x3035, 0x3036, 0x3037, ...

or

static final char[] HEX256 = new char[]{
        0x30_30, 0x30_31, 0x30_32, 0x30_33, 0x30_34, 0x30_35, 0x30_36, 0x30_37, 
...

src/java.base/share/classes/java/lang/Long.java line 492:

> 490:         final char[] hex256 = HEX256;
> 491: 
> 492:         char i = hex256[((int) (msb >> 56)) & 255];

Masks are easier to read when expressed as hex literals.

char i = hex256[((int) (msb >> 56)) & 0xFF];
...

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

PR Review Comment: https://git.openjdk.org/jdk/pull/14578#discussion_r1236753357
PR Review Comment: https://git.openjdk.org/jdk/pull/14578#discussion_r1236753461

Reply via email to