RFR: 8311207: Cleanup for Optimization for UUID.toString [v13]

温绍锦 duke at openjdk.org
Fri Sep 8 20:36:34 UTC 2023


On Fri, 8 Sep 2023 20:13:01 GMT, Roger Riggs <rriggs at openjdk.org> wrote:

>> 温绍锦 has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   add DIGITS description
>
> src/java.base/share/classes/java/util/HexDigits.java line 81:
> 
>> 79:             for (int j = 0; j < 16; j++) {
>> 80:                 short hi = (short) ((j < 10 ? j + '0' : j - 10 + 'a') << 8);
>> 81:                 digits[(i << 4) + j] = (short) (lo | hi);
> 
> The part that is counter-intuitive is that the bits that are shifted left appear to the right of the bits that are not shifted. (the actual bits are correct, either way, but it reads oddly). In a short, the resulting bits would be `hhll`.
> Suggestion:
> 
>                 digits[(i << 4) + j] = (short) (hi | lo);
> 
> Similarly, the returns of the other `packDigits` methods do not read MSB to LSB.

You are right, I have changed

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

PR Review Comment: https://git.openjdk.org/jdk/pull/14745#discussion_r1320310958


More information about the core-libs-dev mailing list