@@ -257,10 +257,12 @@ public unsafe static (int totalbyteadjustment,int backedupByHowMuch,int ascii,in
257
257
{
258
258
if ( ( pInputBuffer [ - i ] & 0b11000000 ) != 0b10000000 )
259
259
{
260
+ string binaryString = Convert . ToString ( pInputBuffer [ - i ] , 2 ) . PadLeft ( 8 , '0' ) ;
261
+ // Console.WriteLine($"Stopping at byte {binaryString}"); //debug
260
262
break ;
261
263
}
262
264
contbyteadjust -= 1 ;
263
-
265
+
264
266
}
265
267
if ( ( pInputBuffer [ - i ] & 0b10000000 ) == 0 ) {
266
268
return ( 0 , i , - 1 , contbyteadjust , 0 ) ; // We must have that i == 1
@@ -277,14 +279,14 @@ public unsafe static (int totalbyteadjustment,int backedupByHowMuch,int ascii,in
277
279
278
280
public static ( int utfadjust , int scalaradjust ) CalculateN2N3FinalSIMDAdjustments ( int asciibytes , int n4 , int contbytes , int totalbyte )
279
281
{
280
- Console . WriteLine ( "---------" ) ; //debug
281
- Console . WriteLine ( "CalculateN2N3FinalSIMDAdjustments's input debug. This is ascii count:" + asciibytes + " n4: " + n4 + " contbytes:" + contbytes + " totalbytes:" + totalbyte ) ; //debug
282
+ // Console.WriteLine("---------"); //debug
283
+ // Console.WriteLine("CalculateN2N3FinalSIMDAdjustments's input debug. This is ascii count:" + asciibytes + " n4: " + n4 + " contbytes:" + contbytes + " totalbytes:" + totalbyte);//debug
282
284
int n3 = asciibytes - 2 * n4 + 2 * contbytes - totalbyte ;
283
285
int n2 = - 2 * asciibytes + n4 - 3 * contbytes + 2 * totalbyte ;
284
286
int utfadjust = - 2 * n4 - 2 * n3 - n2 ;
285
287
int scalaradjust = - n4 ;
286
288
287
- Console . WriteLine ( "CalculateN2N3FinalSIMDAdjustments's output debug. This is n3 count:" + n3 + " n2: " + n2 + " utfadjust:" + utfadjust + " scalaradjust:" + scalaradjust ) ; //debug
289
+ // Console.WriteLine("CalculateN2N3FinalSIMDAdjustments's output debug. This is n3 count:" + n3 + " n2: " + n2 + " utfadjust:" + utfadjust + " scalaradjust:" + scalaradjust);//debug
288
290
289
291
return ( utfadjust , scalaradjust ) ;
290
292
}
@@ -301,7 +303,9 @@ public unsafe static (int utfadjust, int scalaradjust) calculateErrorPathadjust(
301
303
( adjusttotalbyte , backedupByHowMuch , adjustascii , adjustcont , adjustn4 ) = adjustmentFactor ( pInputBuffer + processedLength ) ;
302
304
}
303
305
304
- var ( utfadjust , scalaradjust ) = CalculateN2N3FinalSIMDAdjustments ( asciibytes + adjustascii , n4 + adjustn4 , contbytes + adjustcont , totalbyte + adjusttotalbyte ) ;
306
+ // var (utfadjust,scalaradjust) = CalculateN2N3FinalSIMDAdjustments( asciibytes + adjustascii, n4 + adjustn4, contbytes + adjustcont, totalbyte + adjusttotalbyte);
307
+ var ( utfadjust , scalaradjust ) = CalculateN2N3FinalSIMDAdjustments ( asciibytes , n4 , contbytes , totalbyte + adjusttotalbyte ) ;
308
+
305
309
306
310
return ( utfadjust , scalaradjust ) ;
307
311
}
@@ -461,9 +465,9 @@ public unsafe static (int utfadjust, int scalaradjust) calculateErrorPathadjust(
461
465
462
466
public unsafe static byte * GetPointerToFirstInvalidByteAvx2 ( byte * pInputBuffer , int inputLength , out int utf16CodeUnitCountAdjustment , out int scalarCountAdjustment )
463
467
{
464
- Console . ForegroundColor = ConsoleColor . Blue ; //debug
465
- Console . WriteLine ( "-------------------------------------" ) ; //debug
466
- Console . ResetColor ( ) ; //debug
468
+ // Console.ForegroundColor = ConsoleColor.Blue; //debug
469
+ // Console.WriteLine("-------------------------------------");//debug
470
+ // Console.ResetColor();//debug
467
471
468
472
int processedLength = 0 ;
469
473
int TempUtf16CodeUnitCountAdjustment = 0 ;
@@ -657,7 +661,7 @@ public unsafe static (int utfadjust, int scalaradjust) calculateErrorPathadjust(
657
661
Vector256 < byte > error = Avx2 . Xor ( must23As80 , sc ) ;
658
662
if ( ! Avx2 . TestZ ( error , error ) )
659
663
{
660
- Console . WriteLine ( $ "--Error! @ { processedLength } bytes") ; //debug
664
+ // Console.WriteLine($"--Error! @ {processedLength} bytes");//debug
661
665
int totalbyteasciierror = processedLength - start_point ;
662
666
var ( utfadjustasciierror , scalaradjustasciierror ) = calculateErrorPathadjust ( start_point , processedLength , pInputBuffer , asciibytes , n4 , contbytes ) ;
663
667
@@ -686,7 +690,7 @@ public unsafe static (int utfadjust, int scalaradjust) calculateErrorPathadjust(
686
690
processedLength -= i ;
687
691
n4 += tempn4 ; // this is + because the adjustment function returns something negative already
688
692
contbytes += tempcont ;
689
- Console . WriteLine ( $ "Unterminated! @ { processedLength } Backing up by { i } ") ; //debug
693
+ // Console.WriteLine($"Unterminated! @ {processedLength} Backing up by {i}"); //debug
690
694
}
691
695
692
696
@@ -740,8 +744,8 @@ public unsafe static (int utfadjust, int scalaradjust) calculateErrorPathadjust(
740
744
int totalbyte = processedLength - start_point ;
741
745
var ( utf16adjust , scalaradjust ) = CalculateN2N3FinalSIMDAdjustments ( asciibytes , n4 , contbytes , totalbyte ) ;
742
746
743
- utf16CodeUnitCountAdjustment = utf16adjust ;
744
- scalarCountAdjustment = scalaradjust ;
747
+ TempUtf16CodeUnitCountAdjustment = utf16adjust ;
748
+ TempScalarCountAdjustment = scalaradjust ;
745
749
}
746
750
747
751
0 commit comments