RFR: 8353741: Eliminate table lookup in UUID.toString [v6]

Johannes Graham duke at openjdk.org
Wed May 21 00:23:52 UTC 2025


On Tue, 20 May 2025 21:53:21 GMT, Shaojin Wen <swen at openjdk.org> wrote:

>> src/java.base/share/classes/java/util/UUID.java line 528:
>> 
>>> 526:      * <pre>
>>> 527:      * Input:  0x0123456789ABCDEF
>>> 528:      * Output: 0x3031323334353637 ('0','1','2','3','4','5','6','7' in ASCII)
>> 
>> Only the low 32 bits are used, the example only needs to show the input ox 0x0123457.
>> Or change the signature to accept an `int`.
>
> Because the input of Long.expand is long, if the parameter is int, it will cause a redundant conversion process of long -> int -> long.

I think the issue is just the example input and output should be something like:

Input: 0xABCDEF01
Output: 0x3130666564636261

to demonstrate that it is the low-order bits that are used, as well as that the digit order is reversed in the result.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/22928#discussion_r2099071960


More information about the core-libs-dev mailing list