Skip to content

Commit

Permalink
Use SequenceEqual in BigInteger.Equals (#91416)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rob-Hague authored Oct 30, 2023
1 parent 3295789 commit 44a5abd
Showing 1 changed file with 1 addition and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1137,19 +1137,7 @@ public bool Equals(BigInteger other)
AssertValid();
other.AssertValid();

if (_sign != other._sign)
return false;
if (_bits == other._bits)
// _sign == other._sign && _bits == null && other._bits == null
return true;

if (_bits == null || other._bits == null)
return false;
int cu = _bits.Length;
if (cu != other._bits.Length)
return false;
int cuDiff = GetDiffLength(_bits, other._bits, cu);
return cuDiff == 0;
return _sign == other._sign && _bits.AsSpan().SequenceEqual(other._bits);
}

public int CompareTo(long other)
Expand Down

0 comments on commit 44a5abd

Please sign in to comment.