@@ -14,7 +14,7 @@ public static void ToString(Vector128<byte> v)
14
14
{
15
15
Span < byte > b = stackalloc byte [ 16 ] ;
16
16
v . CopyTo ( b ) ;
17
- // Console.WriteLine(Convert.ToHexString(b));
17
+ // Console .WriteLine(Convert.ToHexString(b));
18
18
}
19
19
20
20
// Returns &inputBuffer[inputLength] if the input buffer is valid.
@@ -480,7 +480,7 @@ private unsafe static (int utfadjust, int scalaradjust) calculateErrorPathadjust
480
480
481
481
public unsafe static byte * GetPointerToFirstInvalidByteSse ( byte * pInputBuffer , int inputLength , out int utf16CodeUnitCountAdjustment , out int scalarCountAdjustment )
482
482
{
483
- // Console.WriteLine("-------------------Calling function--------------------");
483
+ // Console .WriteLine("-------------------Calling function--------------------");
484
484
int processedLength = 0 ;
485
485
if ( pInputBuffer == null || inputLength <= 0 )
486
486
{
@@ -510,7 +510,7 @@ private unsafe static (int utfadjust, int scalaradjust) calculateErrorPathadjust
510
510
511
511
if ( processedLength + 16 < inputLength )
512
512
{
513
- // Console.WriteLine("-------SIMD kicking in-------");
513
+ // Console .WriteLine("-------SIMD kicking in-------");
514
514
Vector128 < byte > prevInputBlock = Vector128 < byte > . Zero ;
515
515
516
516
Vector128 < byte > maxValue = Vector128 . Create (
@@ -591,23 +591,23 @@ private unsafe static (int utfadjust, int scalaradjust) calculateErrorPathadjust
591
591
int n4 = 0 ; // number of 4-byte sequences that start in this block
592
592
for ( ; processedLength + 16 <= inputLength ; processedLength += 16 )
593
593
{
594
- // Console.WriteLine($"Processing {processedLength} bytes", processedLength);
594
+ // Console .WriteLine($"Processing {processedLength} bytes", processedLength);
595
595
596
596
Vector128 < byte > currentBlock = Avx . LoadVector128 ( pInputBuffer + processedLength ) ;
597
- int mask = Sse42 . MoveMask ( currentBlock . AsDouble ( ) ) ;
598
- // ToString(currentBlock);
599
- // Console.WriteLine($"{mask}");
597
+ int mask = Sse42 . MoveMask ( currentBlock ) ;
598
+ // ToString (currentBlock);
599
+ // // Console .WriteLine($"{mask}");
600
600
if ( mask == 0 )
601
601
{
602
602
// We have an ASCII block, no need to process it, but
603
603
// we need to check if the previous block was incomplete.
604
604
//
605
605
606
- // Console.WriteLine("Found all ASCII");
606
+ // Console .WriteLine("Found all ASCII");
607
607
// ToString(prevIncomplete);
608
608
if ( ! Sse41 . TestZ ( prevIncomplete , prevIncomplete ) )
609
609
{
610
- // Console.WriteLine($"Found all-ascii but previous is incomplete.Triggering Rewind");
610
+ // // Console .WriteLine($"Found all-ascii but previous is incomplete.Triggering Rewind");
611
611
int off = processedLength >= 3 ? processedLength - 3 : processedLength ;
612
612
byte * invalidBytePointer = SimdUnicode . UTF8 . SimpleRewindAndValidateWithErrors ( 16 - 3 , pInputBuffer + processedLength - 3 , inputLength - processedLength + 3 ) ;
613
613
// So the code is correct up to invalidBytePointer
@@ -627,7 +627,7 @@ private unsafe static (int utfadjust, int scalaradjust) calculateErrorPathadjust
627
627
}
628
628
else // Contains non-ASCII characters, we need to do non-trivial processing
629
629
{
630
- // Console.WriteLine("Contains ASCII characters, firing standard SIMD routine");
630
+ // Console .WriteLine("Contains ASCII characters, firing standard SIMD routine");
631
631
// Use SubtractSaturate to effectively compare if bytes in block are greater than markers.
632
632
// Contains non-ASCII characters, we need to do non-trivial processing
633
633
Vector128 < byte > prev1 = Ssse3 . AlignRight ( currentBlock , prevInputBlock , ( byte ) ( 16 - 1 ) ) ;
@@ -638,7 +638,7 @@ private unsafe static (int utfadjust, int scalaradjust) calculateErrorPathadjust
638
638
Vector128 < byte > prev2 = Ssse3 . AlignRight ( currentBlock , prevInputBlock , ( byte ) ( 16 - 2 ) ) ;
639
639
Vector128 < byte > prev3 = Ssse3 . AlignRight ( currentBlock , prevInputBlock , ( byte ) ( 16 - 3 ) ) ;
640
640
prevInputBlock = currentBlock ;
641
- // Console.WriteLine("PrevIncomplete:");
641
+ // // Console .WriteLine("PrevIncomplete:");
642
642
// ToString(prevIncomplete);
643
643
644
644
Vector128 < byte > isThirdByte = Sse2 . SubtractSaturate ( prev2 , thirdByte ) ;
@@ -649,7 +649,7 @@ private unsafe static (int utfadjust, int scalaradjust) calculateErrorPathadjust
649
649
650
650
if ( ! Sse42 . TestZ ( error , error ) )
651
651
{
652
- // Console.WriteLine($"Found error! rewinding...");
652
+ // Console .WriteLine($"Found error! rewinding...");
653
653
654
654
byte * invalidBytePointer ;
655
655
if ( processedLength == 0 )
@@ -683,10 +683,10 @@ private unsafe static (int utfadjust, int scalaradjust) calculateErrorPathadjust
683
683
// important: we just update asciibytes if there was no error.
684
684
// We count the number of ascii bytes in the block using just some simple arithmetic
685
685
// and no expensive operation:
686
- asciibytes += ( int ) ( 32 - Popcnt . PopCount ( ( uint ) mask ) ) ;
686
+ asciibytes += ( int ) ( 16 - Popcnt . PopCount ( ( uint ) mask ) ) ;
687
687
}
688
688
689
- // Console.WriteLine($"-----SIMD finished , calling scalar:");
689
+ // Console .WriteLine($"-----SIMD finished , calling scalar:");
690
690
691
691
// We may still have an error.
692
692
if ( processedLength < inputLength || ! Sse42 . TestZ ( prevIncomplete , prevIncomplete ) )
0 commit comments