Skip to content

Commit

Permalink
Cleanup BigNumber.Parse calls
Browse files Browse the repository at this point in the history
  • Loading branch information
huoyaoyuan committed May 9, 2023
1 parent d5c7099 commit fe2f087
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,8 @@ public static BigInteger Parse(string value, IFormatProvider? provider)

public static BigInteger Parse(string value, NumberStyles style, IFormatProvider? provider)
{
return BigNumber.ParseBigInteger(value, style, NumberFormatInfo.GetInstance(provider));
ArgumentNullException.ThrowIfNull(value);
return Parse(value.AsSpan(), style, NumberFormatInfo.GetInstance(provider));
}

public static bool TryParse([NotNullWhen(true)] string? value, out BigInteger result)
Expand All @@ -685,7 +686,7 @@ public static bool TryParse([NotNullWhen(true)] string? value, out BigInteger re

public static bool TryParse([NotNullWhen(true)] string? value, NumberStyles style, IFormatProvider? provider, out BigInteger result)
{
return BigNumber.TryParseBigInteger(value, style, NumberFormatInfo.GetInstance(provider), out result) == BigNumber.ParsingStatus.OK;
return TryParse(value.AsSpan(), style, NumberFormatInfo.GetInstance(provider), out result);
}

public static BigInteger Parse(ReadOnlySpan<char> value, NumberStyles style = NumberStyles.Integer, IFormatProvider? provider = null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,17 +326,6 @@ internal static bool TryValidateParseStyleInteger(NumberStyles style, [NotNullWh
return true;
}

internal static ParsingStatus TryParseBigInteger(string? value, NumberStyles style, NumberFormatInfo info, out BigInteger result)
{
if (value == null)
{
result = default;
return ParsingStatus.Failed;
}

return TryParseBigInteger(value.AsSpan(), style, info, out result);
}

internal static unsafe ParsingStatus TryParseBigInteger(ReadOnlySpan<char> value, NumberStyles style, NumberFormatInfo info, out BigInteger result)
{
if (!TryValidateParseStyleInteger(style, out ArgumentException? e))
Expand Down Expand Up @@ -392,13 +381,6 @@ internal static unsafe ParsingStatus TryParseBigIntegerNumber(ReadOnlySpan<char>
return ret;
}

internal static BigInteger ParseBigInteger(string value, NumberStyles style, NumberFormatInfo info)
{
ArgumentNullException.ThrowIfNull(value);

return ParseBigInteger(value.AsSpan(), style, info);
}

internal static BigInteger ParseBigInteger(ReadOnlySpan<char> value, NumberStyles style, NumberFormatInfo info)
{
if (!TryValidateParseStyleInteger(style, out ArgumentException? e))
Expand Down

0 comments on commit fe2f087

Please sign in to comment.