RFR: 8356891: Some code simplifications for basic BigIntegers' bit operations [v6]
fabioromano1
duke at openjdk.org
Fri May 16 13:32:54 UTC 2025
On Thu, 15 May 2025 22:43:54 GMT, Shaojin Wen <swen at openjdk.org> wrote:
>> fabioromano1 has updated the pull request incrementally with one additional commit since the last revision:
>>
>> make magBitLength() an instance method
>
> src/java.base/share/classes/java/math/BigInteger.java line 3860:
>
>> 3858: && Integer.lowestOneBit(mag[0]) == mag[0]
>> 3859: && numberOfTrailingZeroInts() == mag.length - 1
>> 3860: ? magBitLength() - 1 : magBitLength();
>
> Suggestion:
>
> int[] mag = this.mag;
> return magBitLength()
> - (signum < 0
> // Check if magnitude is a power of two
> && Integer.lowestOneBit(mag[0]) == mag[0]
> && numberOfTrailingZeroInts() == mag.length - 1
> ? 1 : 0);
>
>
> In this way, codeSize will drop from 52 to 45
What is the usefulness of doing `int[] mag = this.mag;` at line 3856?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25166#discussion_r2093057326
More information about the core-libs-dev
mailing list