From 563dd5d5dcf3e6db09f42e7b69d8991a7fc6f4ee Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Sat, 3 Feb 2024 14:53:29 +0800 Subject: [PATCH] Ue AOOE.ThrowIf method --- src/libraries/Common/src/System/Number.Formatting.Common.cs | 5 +---- .../System.Runtime.Numerics/src/System/ThrowHelper.cs | 6 ------ 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/src/libraries/Common/src/System/Number.Formatting.Common.cs b/src/libraries/Common/src/System/Number.Formatting.Common.cs index 43c9fb34194ce..cb0f5fba07ea1 100644 --- a/src/libraries/Common/src/System/Number.Formatting.Common.cs +++ b/src/libraries/Common/src/System/Number.Formatting.Common.cs @@ -764,10 +764,7 @@ private static unsafe void FormatFixed( } groupSizeCount += groupDigits[groupSizeIndex]; - if ((groupSizeCount | bufferSize) < 0) - { - ThrowHelper.ThrowArgumentOutOfRangeException(); // If we overflow - } + ArgumentOutOfRangeException.ThrowIfNegative(groupSizeCount | bufferSize, string.Empty); // If we overflow } groupSize = groupSizeCount == 0 ? 0 : groupDigits[0]; // If you passed in an array with one entry as 0, groupSizeCount == 0 diff --git a/src/libraries/System.Runtime.Numerics/src/System/ThrowHelper.cs b/src/libraries/System.Runtime.Numerics/src/System/ThrowHelper.cs index 55a4b5a35e895..a81589e2526d2 100644 --- a/src/libraries/System.Runtime.Numerics/src/System/ThrowHelper.cs +++ b/src/libraries/System.Runtime.Numerics/src/System/ThrowHelper.cs @@ -32,11 +32,5 @@ internal static void ThrowFormatException_BadFormatSpecifier() { throw new FormatException(SR.Argument_BadFormatSpecifier); } - - [DoesNotReturn] - internal static void ThrowArgumentOutOfRangeException() - { - throw new ArgumentOutOfRangeException(); - } } }