On Tue, 7 Mar 2023 14:35:22 GMT, Adam Sotona <[email protected]> wrote:
>> src/java.base/share/classes/jdk/internal/classfile/impl/EntryMap.java line
>> 176:
>>
>>> 174: }
>>> 175:
>>> 176: public static long nextPowerOfTwo( long x ) {
>>
>> If you like you can change the implementation to be:
>>
>> x = -1 >>> Long.numberOfLeadingZeros(x - 1);
>> return x + 1;
>>
>> See `ConcurrentHashMap`.
>
> `Long:numberOfLeadingZeros` implementation uses more method calls,
> conditional statements and binary operations. I would prefer to stick with
> the current implementation for its speed and simplicity.
`numberOfLeadingZeros` is an intrinsic, so it will compile down to a machine
instruction. Up to you.
-------------
PR: https://git.openjdk.org/jdk/pull/10982