@@ -124,7 +124,8 @@ private static (int utfAdjust, int scalarAdjust) GetFinalScalarUtfAdjustments(by
124124 } // Too short
125125 // range check
126126 codePoint = ( uint ) ( firstByte & 0b00011111 ) << 6 | ( uint ) ( buf [ pos + 1 ] & 0b00111111 ) ;
127- if ( ( codePoint < 0x80 ) || ( 0x7ff < codePoint ) )
127+ // codePoint is necessarily <= 0x7ff
128+ if ( codePoint < 0x80 )
128129 {
129130 return buf + pos ;
130131 } // Overlong
@@ -141,7 +142,8 @@ private static (int utfAdjust, int scalarAdjust) GetFinalScalarUtfAdjustments(by
141142 ( uint ) ( buf [ pos + 1 ] & 0b00111111 ) << 6 |
142143 ( uint ) ( buf [ pos + 2 ] & 0b00111111 ) ;
143144 // Either overlong or too large:
144- if ( ( codePoint < 0x800 ) || ( 0xffff < codePoint ) ||
145+ // codePoint is necessarily <= 0xffff
146+ if ( ( codePoint < 0x800 ) ||
145147 ( 0xd7ff < codePoint && codePoint < 0xe000 ) )
146148 {
147149 return buf + pos ;
@@ -238,7 +240,8 @@ private static (int utfAdjust, int scalarAdjust) GetFinalScalarUtfAdjustments(by
238240 } // Too short
239241 // range check
240242 codePoint = ( uint ) ( firstByte & 0b00011111 ) << 6 | ( uint ) ( pInputBuffer [ pos + 1 ] & 0b00111111 ) ;
241- if ( ( codePoint < 0x80 ) || ( 0x7ff < codePoint ) )
243+ // codePoint is necessarily <= 0x7ff
244+ if ( codePoint < 0x80 )
242245 {
243246 utf16CodeUnitCountAdjustment = TempUtf16CodeUnitCountAdjustment ;
244247 scalarCountAdjustment = TempScalarCountAdjustment ;
@@ -261,7 +264,8 @@ private static (int utfAdjust, int scalarAdjust) GetFinalScalarUtfAdjustments(by
261264 ( uint ) ( pInputBuffer [ pos + 1 ] & 0b00111111 ) << 6 |
262265 ( uint ) ( pInputBuffer [ pos + 2 ] & 0b00111111 ) ;
263266 // Either overlong or too large:
264- if ( ( codePoint < 0x800 ) || ( 0xffff < codePoint ) ||
267+ // codePoint is necessarily <= 0xffff
268+ if ( ( codePoint < 0x800 ) ||
265269 ( 0xd7ff < codePoint && codePoint < 0xe000 ) )
266270 {
267271 utf16CodeUnitCountAdjustment = TempUtf16CodeUnitCountAdjustment ;
0 commit comments