Skip to content

Commit ab8b95c

Browse files
committed
put back code deleted by mistake
1 parent 9e31966 commit ab8b95c

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

src/UTF8.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,38 @@ public unsafe static void AdjustForSkippedBytes(byte* pInputBuffer,// int skippe
641641
TempScalarCountAdjustment -= (int)fourByteCount;
642642

643643
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+
}
644676
}
645677
}
646678
}

0 commit comments

Comments
 (0)