Skip to content

Commit

Permalink
Describe rationale for identity check of BigInteger values in the code.
Browse files Browse the repository at this point in the history
  • Loading branch information
wrandelshofer committed Jun 16, 2023
1 parent 6bb73c2 commit 0a5ca6a
Showing 1 changed file with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,8 @@ static BigInteger multiply(BigInteger a, BigInteger b) {
if (b.signum() == 0 || a.signum() == 0) {
return BigInteger.ZERO;
}
// Squaring is slightly faster than multiplication.
// We check for identity here and not for equality, because an equality check of big integers is very expensive.
if (b == a) {
return square(b);
}
Expand Down

0 comments on commit 0a5ca6a

Please sign in to comment.