diff options
author | Stephen Toub <stoub@microsoft.com> | 2018-04-05 02:15:27 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-05 02:15:27 +0300 |
commit | 85062446c4e5af0c205f646e0ae720e160b20e85 (patch) | |
tree | 32a0b8ffebc4ff5fd9d521565fd8b428574bcbc0 /src | |
parent | 5d669ef9823a20ec589fc3b7d47a7f5aa1070893 (diff) |
Delete unnecessary long.MinValue formatting code (#28820)
The argument for this code is that -long.MinValue overflows to -long.MinValue, but casting -long.MinValue to ulong does the "right thing".
Diffstat (limited to 'src')
2 files changed, 0 insertions, 48 deletions
diff --git a/src/System.Memory/src/System/Buffers/Text/Utf8Formatter/Utf8Formatter.Integer.Signed.D.cs b/src/System.Memory/src/System/Buffers/Text/Utf8Formatter/Utf8Formatter.Integer.Signed.D.cs index ddfd4ac544..7532f0cf15 100644 --- a/src/System.Memory/src/System/Buffers/Text/Utf8Formatter/Utf8Formatter.Integer.Signed.D.cs +++ b/src/System.Memory/src/System/Buffers/Text/Utf8Formatter/Utf8Formatter.Integer.Signed.D.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using System.Diagnostics; using System.Runtime.CompilerServices; namespace System.Buffers.Text @@ -20,32 +19,9 @@ namespace System.Buffers.Text { insertNegationSign = true; value = -value; - if (value < 0) - { - Debug.Assert(value == Int64.MinValue); - return TryFormatInt64D_MinValue(precision, destination, out bytesWritten); - } } return TryFormatUInt64D((ulong)value, precision, destination, insertNegationSign, out bytesWritten); } - - [MethodImpl(MethodImplOptions.NoInlining)] - private static bool TryFormatInt64D_MinValue(byte precision, Span<byte> destination, out int bytesWritten) - { - // Int64.MinValue must be treated specially since its two's complement negation doesn't fit into 64 bits. - // Instead, we'll perform one's complement negation and fix up the +1 later (-x := ~x + 1). - // Int64.MinValue = -9,223,372,036,854,775,808 - // Int64.MaxValue = 9,223,372,036,854,775,807 - - bool retVal = TryFormatUInt64D((ulong)Int64.MaxValue, precision, destination, insertNegationSign: true, out int tempBytesWritten); - if (retVal) - { - destination[tempBytesWritten - 1]++; // bump the last ASCII '7' to an '8' - } - - bytesWritten = tempBytesWritten; - return retVal; - } } } diff --git a/src/System.Memory/src/System/Buffers/Text/Utf8Formatter/Utf8Formatter.Integer.Signed.N.cs b/src/System.Memory/src/System/Buffers/Text/Utf8Formatter/Utf8Formatter.Integer.Signed.N.cs index 412ca8eccd..1c01b8d60d 100644 --- a/src/System.Memory/src/System/Buffers/Text/Utf8Formatter/Utf8Formatter.Integer.Signed.N.cs +++ b/src/System.Memory/src/System/Buffers/Text/Utf8Formatter/Utf8Formatter.Integer.Signed.N.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using System.Diagnostics; using System.Runtime.CompilerServices; namespace System.Buffers.Text @@ -20,32 +19,9 @@ namespace System.Buffers.Text { insertNegationSign = true; value = -value; - if (value < 0) - { - Debug.Assert(value == Int64.MinValue); - return TryFormatInt64N_MinValue(precision, destination, out bytesWritten); - } } return TryFormatUInt64N((ulong)value, precision, destination, insertNegationSign, out bytesWritten); } - - [MethodImpl(MethodImplOptions.NoInlining)] - private static bool TryFormatInt64N_MinValue(byte precision, Span<byte> destination, out int bytesWritten) - { - // Int64.MinValue must be treated specially since its two's complement negation doesn't fit into 64 bits. - // Instead, we'll perform one's complement negation and fix up the +1 later (-x := ~x + 1). - // Int64.MinValue = -9,223,372,036,854,775,808 (26 digits, including minus and commas) - // Int64.MaxValue = 9,223,372,036,854,775,807 - - bool retVal = TryFormatUInt64N((ulong)Int64.MaxValue, precision, destination, insertNegationSign: true, out int tempBytesWritten); - if (retVal) - { - destination[25]++; // bump the last ASCII '7' to an '8' - } - - bytesWritten = tempBytesWritten; - return retVal; - } } } |