From fe2f08795175b56796ca7449a7e6775be86ccb07 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Tue, 9 May 2023 22:33:01 +0800 Subject: [PATCH] Cleanup BigNumber.Parse calls --- .../src/System/Numerics/BigInteger.cs | 5 +++-- .../src/System/Numerics/BigNumber.cs | 18 ------------------ 2 files changed, 3 insertions(+), 20 deletions(-) diff --git a/src/libraries/System.Runtime.Numerics/src/System/Numerics/BigInteger.cs b/src/libraries/System.Runtime.Numerics/src/System/Numerics/BigInteger.cs index 18c55cc62cd00..21390d384c7b6 100644 --- a/src/libraries/System.Runtime.Numerics/src/System/Numerics/BigInteger.cs +++ b/src/libraries/System.Runtime.Numerics/src/System/Numerics/BigInteger.cs @@ -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) @@ -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 value, NumberStyles style = NumberStyles.Integer, IFormatProvider? provider = null) diff --git a/src/libraries/System.Runtime.Numerics/src/System/Numerics/BigNumber.cs b/src/libraries/System.Runtime.Numerics/src/System/Numerics/BigNumber.cs index 86afc1ab59cfc..af0fd8a4cd802 100644 --- a/src/libraries/System.Runtime.Numerics/src/System/Numerics/BigNumber.cs +++ b/src/libraries/System.Runtime.Numerics/src/System/Numerics/BigNumber.cs @@ -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 value, NumberStyles style, NumberFormatInfo info, out BigInteger result) { if (!TryValidateParseStyleInteger(style, out ArgumentException? e)) @@ -392,13 +381,6 @@ internal static unsafe ParsingStatus TryParseBigIntegerNumber(ReadOnlySpan 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 value, NumberStyles style, NumberFormatInfo info) { if (!TryValidateParseStyleInteger(style, out ArgumentException? e))