On Thu, 25 Dec 2025 02:01:31 GMT, Shaojin Wen <[email protected]> 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 with a new target base due to a 
> merge or a rebase. The pull request now contains 24 commits:
> 
>  - Merge remote-tracking branch 'upstream/master' into optim_to_hex_202501
>  - fix merge error
>  - Merge branch 'master' into optim_to_hex_202501
>  - Merge branch 'master' into optim_to_hex_202501
>  - Update src/java.base/share/classes/java/util/UUID.java
>    
>    Co-authored-by: ExE Boss <[email protected]>
>  - Merge remote-tracking branch 'upstream/master' into optim_to_hex_202501
>  - use right shift
>  - use right shift
>  - fix benchmark
>  - Merge remote-tracking branch 'upstream/master' into optim_to_hex_202501
>  - ... and 14 more: https://git.openjdk.org/jdk/compare/73a8629c...d896e365

Changes requested by liach (Reviewer).

src/java.base/share/classes/jdk/internal/util/HexDigits.java line 157:

> 155:      * </pre>
> 156:      *
> 157:      */

Documentation here is too long, hard for reading. I recommend something simple 
like:


Prints an unsigned 4-byte number into 8 hexadecimal digits in an ASCII 
character buffer.
The buffer is represented as a big-endian 8 byte integer.

Input:  0xA__B__C__D__E__F__0__1
Output: 0x61_62_63_64_65_66_30_31


You can just use `///` to write markdown, which is easier to read too.

The performance tricks are in the method already, so I think you can drop them.

Also, let's rename this method to `hex8Be` to indicate the return result is big 
endian, and change the input type to `int` to indicate only the int bits are 
used.

src/java.base/share/classes/jdk/internal/util/HexDigits.java line 181:

> 179:         long m = (i + 0x0606_0606_0606_0606L) & 0x1010_1010_1010_1010L;
> 180: 
> 181:         // Calculate final ASCII values and reverse bytes for proper 
> ordering

Outdated comments, you no longer reverse the bytes

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

PR Review: https://git.openjdk.org/jdk/pull/22942#pullrequestreview-3695099240
PR Review Comment: https://git.openjdk.org/jdk/pull/22942#discussion_r2719048886
PR Review Comment: https://git.openjdk.org/jdk/pull/22942#discussion_r2719051562

Reply via email to