File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -641,6 +641,38 @@ public unsafe static void AdjustForSkippedBytes(byte* pInputBuffer,// int skippe
641
641
TempScalarCountAdjustment -= ( int ) fourByteCount ;
642
642
643
643
prevIncomplete = Avx2 . SubtractSaturate ( currentBlock , maxValue ) ;
644
+
645
+ if ( ! Avx2 . TestZ ( prevIncomplete , prevIncomplete ) )
646
+ {
647
+ // We have an unterminated sequence.
648
+ processedLength -= 3 ;
649
+ for ( int k = 0 ; k < 3 ; k ++ )
650
+ {
651
+ int candidateByte = pInputBuffer [ processedLength + k ] ;
652
+ if ( ( candidateByte & 0b11000000 ) == 0b11000000 )
653
+ {
654
+ // if (k != 0)
655
+ if ( true )
656
+ {
657
+ if ( ( candidateByte & 0b11100000 ) == 0b11000000 ) // Start of a 2-byte sequence
658
+ {
659
+ TempUtf16CodeUnitCountAdjustment += 1 ;
660
+ }
661
+ if ( ( candidateByte & 0b11110000 ) == 0b11100000 ) // Start of a 3-byte sequence
662
+ {
663
+ TempUtf16CodeUnitCountAdjustment += 2 ;
664
+ }
665
+ if ( ( candidateByte & 0b11111000 ) == 0b11110000 ) // Start of a 4-byte sequence
666
+ {
667
+ TempUtf16CodeUnitCountAdjustment += 2 ;
668
+ TempScalarCountAdjustment += 1 ;
669
+ }
670
+ }
671
+ processedLength += k ;
672
+ break ;
673
+ }
674
+ }
675
+ }
644
676
}
645
677
}
646
678
}
You can’t perform that action at this time.
0 commit comments