diff --git a/src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Utf8Parser/Utf8Parser.Number.cs b/src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Utf8Parser/Utf8Parser.Number.cs index 41fdc36cf5620..f39d99fb22083 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Utf8Parser/Utf8Parser.Number.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Utf8Parser/Utf8Parser.Number.cs @@ -84,8 +84,9 @@ private static bool TryParseNumber(ReadOnlySpan source, ref Number.NumberB while (srcIndex != source.Length) { c = source[srcIndex]; + int value = (byte)(c - (byte)('0')); - if ((c -= (byte)('0')) > 9) + if (value > 9) { break; } @@ -102,7 +103,7 @@ private static bool TryParseNumber(ReadOnlySpan source, ref Number.NumberB // for an input that falls evenly between two representable // results. - hasNonZeroTail |= c; + hasNonZeroTail |= value; } } number.HasNonZeroTail = (hasNonZeroTail != 0); @@ -138,8 +139,9 @@ private static bool TryParseNumber(ReadOnlySpan source, ref Number.NumberB while (srcIndex != source.Length) { c = source[srcIndex]; + int value = (byte)(c - (byte)('0')); - if ((c -= (byte)('0')) > 9) + if (value > 9) { break; } @@ -156,7 +158,7 @@ private static bool TryParseNumber(ReadOnlySpan source, ref Number.NumberB // for an input that falls evenly between two representable // results. - hasNonZeroTail |= c; + hasNonZeroTail |= value; } } number.HasNonZeroTail = (hasNonZeroTail != 0);