Skip to content

Commit

Permalink
Use BigInteger(ReadOnlySpan<uint> value, bool negative)
Browse files Browse the repository at this point in the history
  • Loading branch information
kzrnm committed May 12, 2024
1 parent 456bf8e commit f92dff4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -364,11 +364,7 @@ private static ParsingStatus NumberToBigInteger(ref NumberBuffer number, out Big
resultBuffer = resultBuffer.Slice(0, BigIntegerCalculator.ActualLength(resultBuffer));
Debug.Assert(resultBuffer.Length == 0 || resultBuffer[^1] != 0);

result = resultBuffer.Length == 0
? BigInteger.Zero
: resultBuffer is [uint leading] && (leading <= int.MaxValue || number.IsNegative && leading == unchecked((uint)(int.MaxValue + 1)))
? new BigInteger((int)(number.IsNegative ? -leading : leading))
: new BigInteger(number.IsNegative ? -1 : 1, resultBuffer.ToArray());
result = new BigInteger(resultBuffer, number.IsNegative);

if (resultBufferFromPool != null)
ArrayPool<uint>.Shared.Return(resultBufferFromPool);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ internal BigInteger(int n, uint[]? rgu)
/// </summary>
/// <param name="value">The absolute value of the number</param>
/// <param name="negative">The bool indicating the sign of the value.</param>
private BigInteger(ReadOnlySpan<uint> value, bool negative)
internal BigInteger(ReadOnlySpan<uint> value, bool negative)
{
if (value.Length > MaxLength)
{
Expand Down

0 comments on commit f92dff4

Please sign in to comment.