@@ -66,7 +66,7 @@ public static OperationStatus EncodeToUtf8(ReadOnlySpan<byte> bytes, Span<byte>
6666 if ( maxSrcLength != srcLength - 2 )
6767 goto DestinationSmallExit ;
6868
69- if ( isFinalBlock != true )
69+ if ( ! isFinalBlock )
7070 goto NeedMoreDataExit ;
7171
7272 if ( sourceIndex == srcLength - 1 )
@@ -108,7 +108,7 @@ public static OperationStatus EncodeToUtf8(ReadOnlySpan<byte> bytes, Span<byte>
108108 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
109109 public static int GetMaxEncodedToUtf8Length ( int length )
110110 {
111- if ( length < 0 || length > MaximumEncodeLength )
111+ if ( ( uint ) length > MaximumEncodeLength )
112112 ThrowHelper . ThrowArgumentOutOfRangeException ( ExceptionArgument . length ) ;
113113
114114 return ( ( ( length + 2 ) / 3 ) * 4 ) ;
@@ -135,7 +135,7 @@ public static OperationStatus EncodeToUtf8InPlace(Span<byte> buffer, int dataLen
135135 if ( buffer . Length < encodedLength )
136136 goto FalseExit ;
137137
138- int leftover = dataLength - dataLength / 3 * 3 ; // how many bytes after packs of 3
138+ int leftover = dataLength - ( dataLength / 3 ) * 3 ; // how many bytes after packs of 3
139139
140140 int destinationIndex = encodedLength - 4 ;
141141 int sourceIndex = dataLength - leftover ;
@@ -228,6 +228,6 @@ private static int EncodeAndPadTwo(ref byte oneByte, ref byte encodingMap)
228228
229229 private const byte EncodingPad = ( byte ) '=' ; // '=', for padding
230230
231- private const int MaximumEncodeLength = ( int . MaxValue >> 2 ) * 3 ; // 1610612733
231+ private const int MaximumEncodeLength = ( int . MaxValue / 4 ) * 3 ; // 1610612733
232232 }
233233}
0 commit comments