RFR: 8310813: Simplify and modernize equals, hashCode, and compareTo for BigInteger

Raffaello Giulietti rgiulietti at openjdk.org
Mon Jun 26 14:45:04 UTC 2023


On Mon, 26 Jun 2023 14:38:53 GMT, Pavel Rappo <prappo at openjdk.org> wrote:

>> src/java.base/share/classes/java/math/BigInteger.java line 1:
>> 
>>> 1: /*
>> 
>> On L.3932, I think you can simplify
>> 
>>         return signum > val.signum ? 1 : -1;
>> 
>> with
>> 
>>         return signum;
>
> Thanks for looking at this. My reply to both of your comments, is that there are further improvements possible, and I'd be happy to explore such possibilities later. Right now I'm more concerned with `hashCode` and possible performance degradation, which my local benchmarks on arm64 showed approx. 10%.
> 
> On your signum suggestion: signum of 0 is what makes that suggestion inapplicable.

Yep, you're right.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/14630#discussion_r1242313577


More information about the core-libs-dev mailing list