diff options
author | Günther Foidl <gue@korporal.at> | 2018-04-07 00:16:57 +0300 |
---|---|---|
committer | Stephen Toub <stoub@microsoft.com> | 2018-04-07 00:16:57 +0300 |
commit | 11a57828a59479532153b4f8c67aaaeb68eb7d79 (patch) | |
tree | 3b5de51eb63c31319e7e08146cede9534f092517 | |
parent | 3b834c49b451fc23e04c9233d9c008e693a4fc9b (diff) |
Base64Encoder mini changes (#28888)
-rw-r--r-- | src/System.Memory/src/System/Buffers/Text/Base64Encoder.cs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/System.Memory/src/System/Buffers/Text/Base64Encoder.cs b/src/System.Memory/src/System/Buffers/Text/Base64Encoder.cs index 6b243f0a28..9b0a8222d0 100644 --- a/src/System.Memory/src/System/Buffers/Text/Base64Encoder.cs +++ b/src/System.Memory/src/System/Buffers/Text/Base64Encoder.cs @@ -66,7 +66,7 @@ namespace System.Buffers.Text if (maxSrcLength != srcLength - 2) goto DestinationSmallExit; - if (isFinalBlock != true) + if (!isFinalBlock) goto NeedMoreDataExit; if (sourceIndex == srcLength - 1) @@ -108,7 +108,7 @@ namespace System.Buffers.Text [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int GetMaxEncodedToUtf8Length(int length) { - if (length < 0 || length > MaximumEncodeLength) + if ((uint)length > MaximumEncodeLength) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.length); return (((length + 2) / 3) * 4); @@ -135,7 +135,7 @@ namespace System.Buffers.Text if (buffer.Length < encodedLength) goto FalseExit; - int leftover = dataLength - dataLength / 3 * 3; // how many bytes after packs of 3 + int leftover = dataLength - (dataLength / 3) * 3; // how many bytes after packs of 3 int destinationIndex = encodedLength - 4; int sourceIndex = dataLength - leftover; @@ -228,6 +228,6 @@ namespace System.Buffers.Text private const byte EncodingPad = (byte)'='; // '=', for padding - private const int MaximumEncodeLength = (int.MaxValue >> 2) * 3; // 1610612733 + private const int MaximumEncodeLength = (int.MaxValue / 4) * 3; // 1610612733 } } |