On Sun, 11 May 2025 16:08:25 GMT, fabioromano1 <[email protected]> wrote:
>> src/java.base/share/classes/java/math/BigInteger.java line 2828:
>>
>>> 2826: * assuming there are no leading zero ints.
>>> 2827: */
>>> 2828: private static int bitLength(int[] val, int len) {
>>
>> This should really be refactored to an instance method `bitLengthUnsigned`
>> or `magBitCount`: the `len` is always `val.length` and the `val` is always
>> the `mag` array of some `BigInteger` from somewhere. Making this an instance
>> method makes code cleaner and allows us to cache if we find this calculation
>> expensive.
>
>> This should really be refactored to an instance method `bitLengthUnsigned`
>> or `magBitCount`
>
> I would prefer `magBitLength` as a name, since `bitCount` is usually referred
> to one's bit count. But before do this, I'd hear the opinion of @rgiulietti
> about that.
> Making this an instance method makes code cleaner and allows us to cache if
> we find this calculation expensive.
I recall that `bitLength` is already cached, so it would be preferable to
replace `bitLength`'s cache with `magBitLength`'s cache if we want to do so.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25166#discussion_r2083564019