Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
SpanHelpers.cs
Go to the documentation of this file.
9
10namespace System;
11
12internal static class SpanHelpers
13{
14 internal readonly struct ComparerComparable<T, TComparer> : IComparable<T> where TComparer : IComparer<T>
15 {
16 private readonly T _value;
17
18 private readonly TComparer _comparer;
19
25
26 [MethodImpl(MethodImplOptions.AggressiveInlining)]
27 public int CompareTo(T other)
28 {
29 return _comparer.Compare(_value, other);
30 }
31 }
32
33 [MethodImpl(MethodImplOptions.AggressiveInlining)]
35 {
36 if (comparable == null)
37 {
39 }
40 return BinarySearch(ref MemoryMarshal.GetReference(span), span.Length, comparable);
41 }
42
44 {
45 int num = 0;
46 int num2 = length - 1;
47 while (num <= num2)
48 {
49 int num3 = num2 + num >>> 1;
50 int num4 = comparable.CompareTo(Unsafe.Add(ref spanStart, num3));
51 if (num4 == 0)
52 {
53 return num3;
54 }
55 if (num4 > 0)
56 {
57 num = num3 + 1;
58 }
59 else
60 {
61 num2 = num3 - 1;
62 }
63 }
64 return ~num;
65 }
66
67 public static int IndexOf(ref byte searchSpace, int searchSpaceLength, ref byte value, int valueLength)
68 {
69 if (valueLength == 0)
70 {
71 return 0;
72 }
73 byte value2 = value;
74 ref byte second = ref Unsafe.Add(ref value, 1);
75 int num = valueLength - 1;
76 int num2 = searchSpaceLength - num;
77 int num3 = 0;
78 while (num2 > 0)
79 {
81 if (num4 == -1)
82 {
83 break;
84 }
85 num2 -= num4;
86 num3 += num4;
87 if (num2 <= 0)
88 {
89 break;
90 }
91 if (SequenceEqual(ref Unsafe.Add(ref searchSpace, num3 + 1), ref second, (nuint)num))
92 {
93 return num3;
94 }
95 num2--;
96 num3++;
97 }
98 return -1;
99 }
100
101 [MethodImpl(MethodImplOptions.AggressiveOptimization)]
102 public static bool Contains(ref byte searchSpace, byte value, int length)
103 {
104 nuint num = 0u;
105 nuint num2 = (uint)length;
107 {
109 }
110 while (true)
111 {
112 if (num2 >= 8)
113 {
114 num2 -= 8;
115 if (value == Unsafe.AddByteOffset(ref searchSpace, num + 0) || value == Unsafe.AddByteOffset(ref searchSpace, num + 1) || value == Unsafe.AddByteOffset(ref searchSpace, num + 2) || value == Unsafe.AddByteOffset(ref searchSpace, num + 3) || value == Unsafe.AddByteOffset(ref searchSpace, num + 4) || value == Unsafe.AddByteOffset(ref searchSpace, num + 5) || value == Unsafe.AddByteOffset(ref searchSpace, num + 6) || value == Unsafe.AddByteOffset(ref searchSpace, num + 7))
116 {
117 break;
118 }
119 num += 8;
120 continue;
121 }
122 if (num2 >= 4)
123 {
124 num2 -= 4;
125 if (value == Unsafe.AddByteOffset(ref searchSpace, num + 0) || value == Unsafe.AddByteOffset(ref searchSpace, num + 1) || value == Unsafe.AddByteOffset(ref searchSpace, num + 2) || value == Unsafe.AddByteOffset(ref searchSpace, num + 3))
126 {
127 break;
128 }
129 num += 4;
130 }
131 while (num2 != 0)
132 {
133 num2--;
134 if (value == Unsafe.AddByteOffset(ref searchSpace, num))
135 {
136 goto end_IL_00bd;
137 }
138 num++;
139 }
140 if (Vector.IsHardwareAccelerated && num < (uint)length)
141 {
142 num2 = ((uint)length - num) & (nuint)(~(Vector<byte>.Count - 1));
143 Vector<byte> left = new Vector<byte>(value);
144 for (; num2 > num; num += (nuint)Vector<byte>.Count)
145 {
147 if (!Vector<byte>.Zero.Equals(other))
148 {
149 goto end_IL_00bd;
150 }
151 }
152 if (num < (uint)length)
153 {
154 num2 = (uint)length - num;
155 continue;
156 }
157 }
158 return false;
159 continue;
161 break;
162 }
163 return true;
164 }
165
166 [MethodImpl(MethodImplOptions.AggressiveOptimization)]
167 public unsafe static int IndexOf(ref byte searchSpace, byte value, int length)
168 {
169 nuint num = 0u;
170 nuint num2 = (uint)length;
172 {
173 if (length >= Vector128<byte>.Count * 2)
174 {
176 }
177 }
179 {
181 }
182 while (true)
183 {
184 if (num2 >= 8)
185 {
186 num2 -= 8;
187 if (value == Unsafe.AddByteOffset(ref searchSpace, num))
188 {
189 goto IL_033c;
190 }
191 if (value == Unsafe.AddByteOffset(ref searchSpace, num + 1))
192 {
193 goto IL_033f;
194 }
195 if (value == Unsafe.AddByteOffset(ref searchSpace, num + 2))
196 {
197 goto IL_0345;
198 }
199 if (value != Unsafe.AddByteOffset(ref searchSpace, num + 3))
200 {
201 if (value != Unsafe.AddByteOffset(ref searchSpace, num + 4))
202 {
203 if (value != Unsafe.AddByteOffset(ref searchSpace, num + 5))
204 {
205 if (value != Unsafe.AddByteOffset(ref searchSpace, num + 6))
206 {
207 if (value == Unsafe.AddByteOffset(ref searchSpace, num + 7))
208 {
209 break;
210 }
211 num += 8;
212 continue;
213 }
214 return (int)(num + 6);
215 }
216 return (int)(num + 5);
217 }
218 return (int)(num + 4);
219 }
220 goto IL_034b;
221 }
222 if (num2 >= 4)
223 {
224 num2 -= 4;
225 if (value == Unsafe.AddByteOffset(ref searchSpace, num))
226 {
227 goto IL_033c;
228 }
229 if (value == Unsafe.AddByteOffset(ref searchSpace, num + 1))
230 {
231 goto IL_033f;
232 }
233 if (value == Unsafe.AddByteOffset(ref searchSpace, num + 2))
234 {
235 goto IL_0345;
236 }
237 if (value == Unsafe.AddByteOffset(ref searchSpace, num + 3))
238 {
239 goto IL_034b;
240 }
241 num += 4;
242 }
243 while (num2 != 0)
244 {
245 num2--;
246 if (value != Unsafe.AddByteOffset(ref searchSpace, num))
247 {
248 num++;
249 continue;
250 }
251 goto IL_033c;
252 }
253 if (Avx2.IsSupported)
254 {
255 if (num < (uint)length)
256 {
257 if ((((uint)Unsafe.AsPointer(ref searchSpace) + num) & (nuint)(Vector256<byte>.Count - 1)) != 0)
258 {
261 int num3 = Sse2.MoveMask(Sse2.CompareEqual(left, right));
262 if (num3 != 0)
263 {
264 return (int)(num + (uint)BitOperations.TrailingZeroCount(num3));
265 }
266 num += (nuint)Vector128<byte>.Count;
267 }
269 if (num2 > num)
270 {
272 do
273 {
276 if (num4 == 0)
277 {
278 num += (nuint)Vector256<byte>.Count;
279 continue;
280 }
281 return (int)(num + (uint)BitOperations.TrailingZeroCount(num4));
282 }
283 while (num2 > num);
284 }
286 if (num2 > num)
287 {
291 if (num5 != 0)
292 {
293 return (int)(num + (uint)BitOperations.TrailingZeroCount(num5));
294 }
295 num += (nuint)Vector128<byte>.Count;
296 }
297 if (num < (uint)length)
298 {
299 num2 = (uint)length - num;
300 continue;
301 }
302 }
303 }
304 else if (Sse2.IsSupported)
305 {
306 if (num < (uint)length)
307 {
310 for (; num2 > num; num += (nuint)Vector128<byte>.Count)
311 {
314 if (num6 != 0)
315 {
316 return (int)(num + (uint)BitOperations.TrailingZeroCount(num6));
317 }
318 }
319 if (num < (uint)length)
320 {
321 num2 = (uint)length - num;
322 continue;
323 }
324 }
325 }
326 else
327 {
329 {
330 }
331 if (Vector.IsHardwareAccelerated && num < (uint)length)
332 {
335 for (; num2 > num; num += (nuint)Vector<byte>.Count)
336 {
338 if (!Vector<byte>.Zero.Equals(vector))
339 {
340 return (int)num + LocateFirstFoundByte(vector);
341 }
342 }
343 if (num < (uint)length)
344 {
345 num2 = (uint)length - num;
346 continue;
347 }
348 }
349 }
350 return -1;
351 IL_0345:
352 return (int)(num + 2);
353 IL_033f:
354 return (int)(num + 1);
355 IL_034b:
356 return (int)(num + 3);
357 IL_033c:
358 return (int)num;
359 }
360 return (int)(num + 7);
361 }
362
363 public static int LastIndexOf(ref byte searchSpace, int searchSpaceLength, ref byte value, int valueLength)
364 {
365 if (valueLength == 0)
366 {
367 return searchSpaceLength;
368 }
369 byte value2 = value;
370 ref byte second = ref Unsafe.Add(ref value, 1);
371 int num = valueLength - 1;
372 int num2 = 0;
373 while (true)
374 {
375 int num3 = searchSpaceLength - num2 - num;
376 if (num3 <= 0)
377 {
378 break;
379 }
381 if (num4 == -1)
382 {
383 break;
384 }
385 if (SequenceEqual(ref Unsafe.Add(ref searchSpace, num4 + 1), ref second, (uint)num))
386 {
387 return num4;
388 }
389 num2 += num3 - num4;
390 }
391 return -1;
392 }
393
394 [MethodImpl(MethodImplOptions.AggressiveOptimization)]
395 public static int LastIndexOf(ref byte searchSpace, byte value, int length)
396 {
397 nuint num = (uint)length;
398 nuint num2 = (uint)length;
400 {
402 }
403 while (true)
404 {
405 if (num2 >= 8)
406 {
407 num2 -= 8;
408 num -= 8;
409 if (value == Unsafe.AddByteOffset(ref searchSpace, num + 7))
410 {
411 break;
412 }
413 if (value != Unsafe.AddByteOffset(ref searchSpace, num + 6))
414 {
415 if (value != Unsafe.AddByteOffset(ref searchSpace, num + 5))
416 {
417 if (value != Unsafe.AddByteOffset(ref searchSpace, num + 4))
418 {
419 if (value != Unsafe.AddByteOffset(ref searchSpace, num + 3))
420 {
421 if (value != Unsafe.AddByteOffset(ref searchSpace, num + 2))
422 {
423 if (value != Unsafe.AddByteOffset(ref searchSpace, num + 1))
424 {
425 if (value != Unsafe.AddByteOffset(ref searchSpace, num))
426 {
427 continue;
428 }
429 goto IL_01ba;
430 }
431 goto IL_01bd;
432 }
433 goto IL_01c3;
434 }
435 goto IL_01c9;
436 }
437 return (int)(num + 4);
438 }
439 return (int)(num + 5);
440 }
441 return (int)(num + 6);
442 }
443 if (num2 >= 4)
444 {
445 num2 -= 4;
446 num -= 4;
447 if (value == Unsafe.AddByteOffset(ref searchSpace, num + 3))
448 {
449 goto IL_01c9;
450 }
451 if (value == Unsafe.AddByteOffset(ref searchSpace, num + 2))
452 {
453 goto IL_01c3;
454 }
455 if (value == Unsafe.AddByteOffset(ref searchSpace, num + 1))
456 {
457 goto IL_01bd;
458 }
459 if (value == Unsafe.AddByteOffset(ref searchSpace, num))
460 {
461 goto IL_01ba;
462 }
463 }
464 while (num2 != 0)
465 {
466 num2--;
467 num--;
468 if (value != Unsafe.AddByteOffset(ref searchSpace, num))
469 {
470 continue;
471 }
472 goto IL_01ba;
473 }
474 if (Vector.IsHardwareAccelerated && num != 0)
475 {
476 num2 = num & (nuint)(~(Vector<byte>.Count - 1));
477 Vector<byte> left = new Vector<byte>(value);
478 while (num2 > (nuint)(Vector<byte>.Count - 1))
479 {
481 if (Vector<byte>.Zero.Equals(vector))
482 {
483 num -= (nuint)Vector<byte>.Count;
484 num2 -= (nuint)Vector<byte>.Count;
485 continue;
486 }
487 return (int)num - Vector<byte>.Count + LocateLastFoundByte(vector);
488 }
489 if (num != 0)
490 {
491 num2 = num;
492 continue;
493 }
494 }
495 return -1;
496 IL_01ba:
497 return (int)num;
498 IL_01c3:
499 return (int)(num + 2);
500 IL_01c9:
501 return (int)(num + 3);
502 IL_01bd:
503 return (int)(num + 1);
504 }
505 return (int)(num + 7);
506 }
507
508 [MethodImpl(MethodImplOptions.AggressiveOptimization)]
509 public static int IndexOfAny(ref byte searchSpace, byte value0, byte value1, int length)
510 {
511 nuint num = 0u;
512 nuint num2 = (uint)length;
514 {
515 nint num3 = (nint)length - (nint)Vector128<byte>.Count;
516 if (num3 >= 0)
517 {
518 num2 = (nuint)num3;
519 goto IL_0212;
520 }
521 }
523 {
524 nint num4 = (nint)length - (nint)Vector<byte>.Count;
525 if (num4 >= 0)
526 {
527 num2 = (nuint)num4;
528 goto IL_0212;
529 }
530 }
531 while (num2 >= 8)
532 {
533 num2 -= 8;
534 uint num5 = Unsafe.AddByteOffset(ref searchSpace, num);
535 if (value0 == num5 || value1 == num5)
536 {
537 goto IL_01e5;
538 }
539 num5 = Unsafe.AddByteOffset(ref searchSpace, num + 1);
540 if (value0 == num5 || value1 == num5)
541 {
542 goto IL_01e8;
543 }
544 num5 = Unsafe.AddByteOffset(ref searchSpace, num + 2);
545 if (value0 == num5 || value1 == num5)
546 {
547 goto IL_01ee;
548 }
549 num5 = Unsafe.AddByteOffset(ref searchSpace, num + 3);
550 if (value0 != num5 && value1 != num5)
551 {
552 num5 = Unsafe.AddByteOffset(ref searchSpace, num + 4);
553 if (value0 != num5 && value1 != num5)
554 {
555 num5 = Unsafe.AddByteOffset(ref searchSpace, num + 5);
556 if (value0 != num5 && value1 != num5)
557 {
558 num5 = Unsafe.AddByteOffset(ref searchSpace, num + 6);
559 if (value0 != num5 && value1 != num5)
560 {
561 num5 = Unsafe.AddByteOffset(ref searchSpace, num + 7);
562 if (value0 != num5 && value1 != num5)
563 {
564 num += 8;
565 continue;
566 }
567 return (int)(num + 7);
568 }
569 return (int)(num + 6);
570 }
571 return (int)(num + 5);
572 }
573 return (int)(num + 4);
574 }
575 goto IL_01f4;
576 }
577 if (num2 >= 4)
578 {
579 num2 -= 4;
580 uint num5 = Unsafe.AddByteOffset(ref searchSpace, num);
581 if (value0 == num5 || value1 == num5)
582 {
583 goto IL_01e5;
584 }
585 num5 = Unsafe.AddByteOffset(ref searchSpace, num + 1);
586 if (value0 == num5 || value1 == num5)
587 {
588 goto IL_01e8;
589 }
590 num5 = Unsafe.AddByteOffset(ref searchSpace, num + 2);
591 if (value0 == num5 || value1 == num5)
592 {
593 goto IL_01ee;
594 }
595 num5 = Unsafe.AddByteOffset(ref searchSpace, num + 3);
596 if (value0 == num5 || value1 == num5)
597 {
598 goto IL_01f4;
599 }
600 num += 4;
601 }
602 while (num2 != 0)
603 {
604 uint num5 = Unsafe.AddByteOffset(ref searchSpace, num);
605 if (value0 != num5 && value1 != num5)
606 {
607 num++;
608 num2--;
609 continue;
610 }
611 goto IL_01e5;
612 }
613 goto IL_01e3;
614 IL_0212:
615 int num6;
616 if (Sse2.IsSupported)
617 {
618 if (Avx2.IsSupported && num2 >= (nuint)Vector128<byte>.Count)
619 {
622 num2 -= (nuint)Vector128<byte>.Count;
623 Vector256<byte> right;
624 while (num2 > num)
625 {
626 right = LoadVector256(ref searchSpace, num);
627 num6 = Avx2.MoveMask(Avx2.Or(Avx2.CompareEqual(left, right), Avx2.CompareEqual(left2, right)));
628 if (num6 == 0)
629 {
630 num += (nuint)Vector256<byte>.Count;
631 continue;
632 }
633 goto IL_033c;
634 }
636 num = num2;
637 num6 = Avx2.MoveMask(Avx2.Or(Avx2.CompareEqual(left, right), Avx2.CompareEqual(left2, right)));
638 if (num6 == 0)
639 {
640 goto IL_01e3;
641 }
642 }
643 else
644 {
648 while (num2 > num)
649 {
652 if (num6 == 0)
653 {
654 num += (nuint)Vector128<byte>.Count;
655 continue;
656 }
657 goto IL_033c;
658 }
660 num = num2;
662 if (num6 == 0)
663 {
664 goto IL_01e3;
665 }
666 }
667 goto IL_033c;
668 }
670 {
671 }
673 {
674 goto IL_01e5;
675 }
679 while (num2 > num)
680 {
683 if (Vector<byte>.Zero.Equals(left5))
684 {
685 num += (nuint)Vector<byte>.Count;
686 continue;
687 }
688 goto IL_03ec;
689 }
691 num = num2;
693 if (Vector<byte>.Zero.Equals(left5))
694 {
695 goto IL_01e3;
696 }
697 goto IL_03ec;
698 IL_033c:
699 num += (nuint)BitOperations.TrailingZeroCount(num6);
700 goto IL_01e5;
701 IL_01e3:
702 return -1;
703 IL_01e5:
704 return (int)num;
705 IL_03ec:
706 num += (nuint)LocateFirstFoundByte(left5);
707 goto IL_01e5;
708 IL_01ee:
709 return (int)(num + 2);
710 IL_01e8:
711 return (int)(num + 1);
712 IL_01f4:
713 return (int)(num + 3);
714 }
715
716 [MethodImpl(MethodImplOptions.AggressiveOptimization)]
717 public static int IndexOfAny(ref byte searchSpace, byte value0, byte value1, byte value2, int length)
718 {
719 nuint num = 0u;
720 nuint num2 = (uint)length;
722 {
723 if (length >= Vector128<byte>.Count * 2)
724 {
726 }
727 }
729 {
731 }
732 while (true)
733 {
734 if (num2 >= 8)
735 {
736 num2 -= 8;
737 uint num3 = Unsafe.AddByteOffset(ref searchSpace, num);
738 if (value0 == num3 || value1 == num3 || value2 == num3)
739 {
740 goto IL_0504;
741 }
742 num3 = Unsafe.AddByteOffset(ref searchSpace, num + 1);
743 if (value0 == num3 || value1 == num3 || value2 == num3)
744 {
745 goto IL_0507;
746 }
747 num3 = Unsafe.AddByteOffset(ref searchSpace, num + 2);
748 if (value0 == num3 || value1 == num3 || value2 == num3)
749 {
750 goto IL_050d;
751 }
752 num3 = Unsafe.AddByteOffset(ref searchSpace, num + 3);
753 if (value0 != num3 && value1 != num3 && value2 != num3)
754 {
755 num3 = Unsafe.AddByteOffset(ref searchSpace, num + 4);
756 if (value0 != num3 && value1 != num3 && value2 != num3)
757 {
758 num3 = Unsafe.AddByteOffset(ref searchSpace, num + 5);
759 if (value0 != num3 && value1 != num3 && value2 != num3)
760 {
761 num3 = Unsafe.AddByteOffset(ref searchSpace, num + 6);
762 if (value0 != num3 && value1 != num3 && value2 != num3)
763 {
764 num3 = Unsafe.AddByteOffset(ref searchSpace, num + 7);
765 if (value0 == num3 || value1 == num3 || value2 == num3)
766 {
767 break;
768 }
769 num += 8;
770 continue;
771 }
772 return (int)(num + 6);
773 }
774 return (int)(num + 5);
775 }
776 return (int)(num + 4);
777 }
778 goto IL_0513;
779 }
780 if (num2 >= 4)
781 {
782 num2 -= 4;
783 uint num3 = Unsafe.AddByteOffset(ref searchSpace, num);
784 if (value0 == num3 || value1 == num3 || value2 == num3)
785 {
786 goto IL_0504;
787 }
788 num3 = Unsafe.AddByteOffset(ref searchSpace, num + 1);
789 if (value0 == num3 || value1 == num3 || value2 == num3)
790 {
791 goto IL_0507;
792 }
793 num3 = Unsafe.AddByteOffset(ref searchSpace, num + 2);
794 if (value0 == num3 || value1 == num3 || value2 == num3)
795 {
796 goto IL_050d;
797 }
798 num3 = Unsafe.AddByteOffset(ref searchSpace, num + 3);
799 if (value0 == num3 || value1 == num3 || value2 == num3)
800 {
801 goto IL_0513;
802 }
803 num += 4;
804 }
805 while (num2 != 0)
806 {
807 num2--;
808 uint num3 = Unsafe.AddByteOffset(ref searchSpace, num);
809 if (value0 != num3 && value1 != num3 && value2 != num3)
810 {
811 num++;
812 continue;
813 }
814 goto IL_0504;
815 }
816 if (Avx2.IsSupported)
817 {
818 if (num < (uint)length)
819 {
821 if (num2 > num)
822 {
826 do
827 {
829 Vector256<byte> left4 = Avx2.CompareEqual(left, right);
833 if (num4 == 0)
834 {
835 num += (nuint)Vector256<byte>.Count;
836 continue;
837 }
838 return (int)(num + (uint)BitOperations.TrailingZeroCount(num4));
839 }
840 while (num2 > num);
841 }
843 if (num2 > num)
844 {
853 if (num5 != 0)
854 {
855 return (int)(num + (uint)BitOperations.TrailingZeroCount(num5));
856 }
857 num += (nuint)Vector128<byte>.Count;
858 }
859 if (num < (uint)length)
860 {
861 num2 = (uint)length - num;
862 continue;
863 }
864 }
865 }
866 else if (Sse2.IsSupported)
867 {
868 if (num < (uint)length)
869 {
874 for (; num2 > num; num += (nuint)Vector128<byte>.Count)
875 {
881 if (num6 != 0)
882 {
883 return (int)(num + (uint)BitOperations.TrailingZeroCount(num6));
884 }
885 }
886 if (num < (uint)length)
887 {
888 num2 = (uint)length - num;
889 continue;
890 }
891 }
892 }
893 else
894 {
896 {
897 }
898 if (Vector.IsHardwareAccelerated && num < (uint)length)
899 {
904 for (; num2 > num; num += (nuint)Vector<byte>.Count)
905 {
908 if (!Vector<byte>.Zero.Equals(vector))
909 {
910 return (int)num + LocateFirstFoundByte(vector);
911 }
912 }
913 if (num < (uint)length)
914 {
915 num2 = (uint)length - num;
916 continue;
917 }
918 }
919 }
920 return -1;
921 IL_0507:
922 return (int)(num + 1);
923 IL_0513:
924 return (int)(num + 3);
925 IL_050d:
926 return (int)(num + 2);
927 IL_0504:
928 return (int)num;
929 }
930 return (int)(num + 7);
931 }
932
933 public static int LastIndexOfAny(ref byte searchSpace, byte value0, byte value1, int length)
934 {
935 nuint num = (uint)length;
936 nuint num2 = (uint)length;
938 {
940 }
941 while (true)
942 {
943 if (num2 >= 8)
944 {
945 num2 -= 8;
946 num -= 8;
947 uint num3 = Unsafe.AddByteOffset(ref searchSpace, num + 7);
948 if (value0 == num3 || value1 == num3)
949 {
950 break;
951 }
952 num3 = Unsafe.AddByteOffset(ref searchSpace, num + 6);
953 if (value0 != num3 && value1 != num3)
954 {
955 num3 = Unsafe.AddByteOffset(ref searchSpace, num + 5);
956 if (value0 != num3 && value1 != num3)
957 {
958 num3 = Unsafe.AddByteOffset(ref searchSpace, num + 4);
959 if (value0 != num3 && value1 != num3)
960 {
961 num3 = Unsafe.AddByteOffset(ref searchSpace, num + 3);
962 if (value0 != num3 && value1 != num3)
963 {
964 num3 = Unsafe.AddByteOffset(ref searchSpace, num + 2);
965 if (value0 != num3 && value1 != num3)
966 {
967 num3 = Unsafe.AddByteOffset(ref searchSpace, num + 1);
968 if (value0 != num3 && value1 != num3)
969 {
970 num3 = Unsafe.AddByteOffset(ref searchSpace, num);
971 if (value0 != num3 && value1 != num3)
972 {
973 continue;
974 }
975 goto IL_027c;
976 }
977 goto IL_027f;
978 }
979 goto IL_0285;
980 }
981 goto IL_028b;
982 }
983 return (int)(num + 4);
984 }
985 return (int)(num + 5);
986 }
987 return (int)(num + 6);
988 }
989 if (num2 >= 4)
990 {
991 num2 -= 4;
992 num -= 4;
993 uint num3 = Unsafe.AddByteOffset(ref searchSpace, num + 3);
994 if (value0 == num3 || value1 == num3)
995 {
996 goto IL_028b;
997 }
998 num3 = Unsafe.AddByteOffset(ref searchSpace, num + 2);
999 if (value0 == num3 || value1 == num3)
1000 {
1001 goto IL_0285;
1002 }
1003 num3 = Unsafe.AddByteOffset(ref searchSpace, num + 1);
1004 if (value0 == num3 || value1 == num3)
1005 {
1006 goto IL_027f;
1007 }
1008 num3 = Unsafe.AddByteOffset(ref searchSpace, num);
1009 if (value0 == num3 || value1 == num3)
1010 {
1011 goto IL_027c;
1012 }
1013 }
1014 while (num2 != 0)
1015 {
1016 num2--;
1017 num--;
1018 uint num3 = Unsafe.AddByteOffset(ref searchSpace, num);
1019 if (value0 != num3 && value1 != num3)
1020 {
1021 continue;
1022 }
1023 goto IL_027c;
1024 }
1025 if (Vector.IsHardwareAccelerated && num != 0)
1026 {
1027 num2 = num & (nuint)(~(Vector<byte>.Count - 1));
1028 Vector<byte> right = new Vector<byte>(value0);
1030 while (num2 > (nuint)(Vector<byte>.Count - 1))
1031 {
1032 Vector<byte> left = LoadVector(ref searchSpace, num - (nuint)Vector<byte>.Count);
1033 Vector<byte> vector = Vector.BitwiseOr(Vector.Equals(left, right), Vector.Equals(left, right2));
1034 if (Vector<byte>.Zero.Equals(vector))
1035 {
1036 num -= (nuint)Vector<byte>.Count;
1037 num2 -= (nuint)Vector<byte>.Count;
1038 continue;
1039 }
1040 return (int)num - Vector<byte>.Count + LocateLastFoundByte(vector);
1041 }
1042 if (num != 0)
1043 {
1044 num2 = num;
1045 continue;
1046 }
1047 }
1048 return -1;
1049 IL_027c:
1050 return (int)num;
1051 IL_028b:
1052 return (int)(num + 3);
1053 IL_027f:
1054 return (int)(num + 1);
1055 IL_0285:
1056 return (int)(num + 2);
1057 }
1058 return (int)(num + 7);
1059 }
1060
1061 public static int LastIndexOfAny(ref byte searchSpace, byte value0, byte value1, byte value2, int length)
1062 {
1063 nuint num = (uint)length;
1064 nuint num2 = (uint)length;
1066 {
1068 }
1069 while (true)
1070 {
1071 if (num2 >= 8)
1072 {
1073 num2 -= 8;
1074 num -= 8;
1075 uint num3 = Unsafe.AddByteOffset(ref searchSpace, num + 7);
1076 if (value0 == num3 || value1 == num3 || value2 == num3)
1077 {
1078 break;
1079 }
1080 num3 = Unsafe.AddByteOffset(ref searchSpace, num + 6);
1081 if (value0 != num3 && value1 != num3 && value2 != num3)
1082 {
1083 num3 = Unsafe.AddByteOffset(ref searchSpace, num + 5);
1084 if (value0 != num3 && value1 != num3 && value2 != num3)
1085 {
1086 num3 = Unsafe.AddByteOffset(ref searchSpace, num + 4);
1087 if (value0 != num3 && value1 != num3 && value2 != num3)
1088 {
1089 num3 = Unsafe.AddByteOffset(ref searchSpace, num + 3);
1090 if (value0 != num3 && value1 != num3 && value2 != num3)
1091 {
1092 num3 = Unsafe.AddByteOffset(ref searchSpace, num + 2);
1093 if (value0 != num3 && value1 != num3 && value2 != num3)
1094 {
1095 num3 = Unsafe.AddByteOffset(ref searchSpace, num + 1);
1096 if (value0 != num3 && value1 != num3 && value2 != num3)
1097 {
1098 num3 = Unsafe.AddByteOffset(ref searchSpace, num);
1099 if (value0 != num3 && value1 != num3 && value2 != num3)
1100 {
1101 continue;
1102 }
1103 goto IL_0310;
1104 }
1105 goto IL_0313;
1106 }
1107 goto IL_0319;
1108 }
1109 goto IL_031f;
1110 }
1111 return (int)(num + 4);
1112 }
1113 return (int)(num + 5);
1114 }
1115 return (int)(num + 6);
1116 }
1117 if (num2 >= 4)
1118 {
1119 num2 -= 4;
1120 num -= 4;
1121 uint num3 = Unsafe.AddByteOffset(ref searchSpace, num + 3);
1122 if (value0 == num3 || value1 == num3 || value2 == num3)
1123 {
1124 goto IL_031f;
1125 }
1126 num3 = Unsafe.AddByteOffset(ref searchSpace, num + 2);
1127 if (value0 == num3 || value1 == num3 || value2 == num3)
1128 {
1129 goto IL_0319;
1130 }
1131 num3 = Unsafe.AddByteOffset(ref searchSpace, num + 1);
1132 if (value0 == num3 || value1 == num3 || value2 == num3)
1133 {
1134 goto IL_0313;
1135 }
1136 num3 = Unsafe.AddByteOffset(ref searchSpace, num);
1137 if (value0 == num3 || value1 == num3 || value2 == num3)
1138 {
1139 goto IL_0310;
1140 }
1141 }
1142 while (num2 != 0)
1143 {
1144 num2--;
1145 num--;
1146 uint num3 = Unsafe.AddByteOffset(ref searchSpace, num);
1147 if (value0 != num3 && value1 != num3 && value2 != num3)
1148 {
1149 continue;
1150 }
1151 goto IL_0310;
1152 }
1153 if (Vector.IsHardwareAccelerated && num != 0)
1154 {
1155 num2 = num & (nuint)(~(Vector<byte>.Count - 1));
1156 Vector<byte> right = new Vector<byte>(value0);
1159 while (num2 > (nuint)(Vector<byte>.Count - 1))
1160 {
1161 Vector<byte> left = LoadVector(ref searchSpace, num - (nuint)Vector<byte>.Count);
1162 Vector<byte> vector = Vector.BitwiseOr(Vector.BitwiseOr(Vector.Equals(left, right), Vector.Equals(left, right2)), Vector.Equals(left, right3));
1163 if (Vector<byte>.Zero.Equals(vector))
1164 {
1165 num -= (nuint)Vector<byte>.Count;
1166 num2 -= (nuint)Vector<byte>.Count;
1167 continue;
1168 }
1169 return (int)num - Vector<byte>.Count + LocateLastFoundByte(vector);
1170 }
1171 if (num != 0)
1172 {
1173 num2 = num;
1174 continue;
1175 }
1176 }
1177 return -1;
1178 IL_0310:
1179 return (int)num;
1180 IL_031f:
1181 return (int)(num + 3);
1182 IL_0319:
1183 return (int)(num + 2);
1184 IL_0313:
1185 return (int)(num + 1);
1186 }
1187 return (int)(num + 7);
1188 }
1189
1190 public unsafe static bool SequenceEqual(ref byte first, ref byte second, nuint length)
1191 {
1192 if (length < (nuint)sizeof(UIntPtr))
1193 {
1194 if (length < 4)
1195 {
1196 uint num = 0u;
1197 nuint num2 = length & 2;
1198 if (num2 != 0)
1199 {
1200 num = LoadUShort(ref first);
1201 num -= LoadUShort(ref second);
1202 }
1203 if ((length & 1) != 0)
1204 {
1205 num |= (uint)(Unsafe.AddByteOffset(ref first, num2) - Unsafe.AddByteOffset(ref second, num2));
1206 }
1207 return num == 0;
1208 }
1209 nuint offset = length - 4;
1210 uint num3 = LoadUInt(ref first) - LoadUInt(ref second);
1211 num3 |= LoadUInt(ref first, offset) - LoadUInt(ref second, offset);
1212 return num3 == 0;
1213 }
1214 if (Unsafe.AreSame(ref first, ref second))
1215 {
1216 goto IL_0087;
1217 }
1218 nuint num5;
1219 nuint num7;
1220 nuint num9;
1223 if (Sse2.IsSupported)
1224 {
1225 if (Avx2.IsSupported && length >= (nuint)Vector256<byte>.Count)
1226 {
1227 nuint num4 = 0u;
1228 num5 = length - (nuint)Vector256<byte>.Count;
1229 if (num5 == 0)
1230 {
1231 goto IL_00ea;
1232 }
1233 while (true)
1234 {
1236 if (Avx2.MoveMask(value) != -1)
1237 {
1238 break;
1239 }
1240 num4 += (nuint)Vector256<byte>.Count;
1241 if (num5 > num4)
1242 {
1243 continue;
1244 }
1245 goto IL_00ea;
1246 }
1247 }
1248 else
1249 {
1250 if (length < 16)
1251 {
1252 goto IL_01fc;
1253 }
1254 nuint num6 = 0u;
1255 num7 = length - 16;
1256 if (num7 == 0)
1257 {
1258 goto IL_0161;
1259 }
1260 while (true)
1261 {
1263 if (Sse2.MoveMask(value2) != 65535)
1264 {
1265 break;
1266 }
1267 num6 += 16;
1268 if (num7 > num6)
1269 {
1270 continue;
1271 }
1272 goto IL_0161;
1273 }
1274 }
1275 }
1276 else
1277 {
1279 {
1280 goto IL_01fc;
1281 }
1282 nuint num8 = 0u;
1283 num9 = length - (nuint)Vector<byte>.Count;
1284 if (num9 == 0)
1285 {
1286 goto IL_01dd;
1287 }
1288 while (!(LoadVector(ref first, num8) != LoadVector(ref second, num8)))
1289 {
1290 num8 += (nuint)Vector<byte>.Count;
1291 if (num9 > num8)
1292 {
1293 continue;
1294 }
1295 goto IL_01dd;
1296 }
1297 }
1298 goto IL_0290;
1299 IL_01dd:
1300 if (LoadVector(ref first, num9) == LoadVector(ref second, num9))
1301 {
1302 goto IL_0087;
1303 }
1304 goto IL_0290;
1305 IL_0278:
1306 nuint num10;
1307 return LoadNUInt(ref first, num10) == LoadNUInt(ref second, num10);
1308 IL_0161:
1310 if (Sse2.MoveMask(value2) == 65535)
1311 {
1312 goto IL_0087;
1313 }
1314 goto IL_0290;
1315 IL_00ea:
1317 if (Avx2.MoveMask(value) == -1)
1318 {
1319 goto IL_0087;
1320 }
1321 goto IL_0290;
1322 IL_0290:
1323 return false;
1324 IL_0087:
1325 return true;
1326 IL_01fc:
1327 if (Sse2.IsSupported)
1328 {
1329 nuint offset2 = length - (nuint)sizeof(UIntPtr);
1330 nuint num11 = LoadNUInt(ref first) - LoadNUInt(ref second);
1331 num11 |= LoadNUInt(ref first, offset2) - LoadNUInt(ref second, offset2);
1332 return num11 == 0;
1333 }
1334 nuint num12 = 0u;
1335 num10 = length - (nuint)sizeof(UIntPtr);
1336 if (num10 == 0)
1337 {
1338 goto IL_0278;
1339 }
1340 while (LoadNUInt(ref first, num12) == LoadNUInt(ref second, num12))
1341 {
1342 num12 += (nuint)sizeof(UIntPtr);
1343 if (num10 > num12)
1344 {
1345 continue;
1346 }
1347 goto IL_0278;
1348 }
1349 goto IL_0290;
1350 }
1351
1352 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1354 {
1355 Vector<ulong> vector = Vector.AsVectorUInt64(match);
1356 ulong num = 0uL;
1357 int i;
1358 for (i = 0; i < Vector<ulong>.Count; i++)
1359 {
1360 num = vector[i];
1361 if (num != 0L)
1362 {
1363 break;
1364 }
1365 }
1366 return i * 8 + LocateFirstFoundByte(num);
1367 }
1368
1369 [MethodImpl(MethodImplOptions.AggressiveOptimization)]
1370 public unsafe static int SequenceCompareTo(ref byte first, int firstLength, ref byte second, int secondLength)
1371 {
1372 nuint num;
1373 uint num6;
1374 nuint num3;
1375 nuint num2;
1376 if (!Unsafe.AreSame(ref first, ref second))
1377 {
1378 num = (uint)(((uint)firstLength < (uint)secondLength) ? firstLength : secondLength);
1379 num2 = 0u;
1380 num3 = num;
1381 if (!Avx2.IsSupported)
1382 {
1383 if (Sse2.IsSupported)
1384 {
1385 if (num3 >= (nuint)Vector128<byte>.Count)
1386 {
1387 num3 -= (nuint)Vector128<byte>.Count;
1388 while (true)
1389 {
1390 uint num4;
1391 if (num3 > num2)
1392 {
1394 if (num4 == 65535)
1395 {
1396 num2 += (nuint)Vector128<byte>.Count;
1397 continue;
1398 }
1399 }
1400 else
1401 {
1402 num2 = num3;
1404 if (num4 == 65535)
1405 {
1406 break;
1407 }
1408 }
1409 uint value = ~num4;
1411 return Unsafe.AddByteOffset(ref first, num2).CompareTo(Unsafe.AddByteOffset(ref second, num2));
1412 }
1413 goto IL_0277;
1414 }
1415 }
1416 else if (Vector.IsHardwareAccelerated && num3 > (nuint)Vector<byte>.Count)
1417 {
1418 for (num3 -= (nuint)Vector<byte>.Count; num3 > num2 && !(LoadVector(ref first, num2) != LoadVector(ref second, num2)); num2 += (nuint)Vector<byte>.Count)
1419 {
1420 }
1421 goto IL_0273;
1422 }
1423 goto IL_021b;
1424 }
1425 if (num3 >= (nuint)Vector256<byte>.Count)
1426 {
1427 num3 -= (nuint)Vector256<byte>.Count;
1428 while (true)
1429 {
1430 uint num5;
1431 if (num3 > num2)
1432 {
1434 if (num5 == uint.MaxValue)
1435 {
1436 num2 += (nuint)Vector256<byte>.Count;
1437 continue;
1438 }
1439 }
1440 else
1441 {
1442 num2 = num3;
1444 if (num5 == uint.MaxValue)
1445 {
1446 break;
1447 }
1448 }
1449 uint value2 = ~num5;
1451 return Unsafe.AddByteOffset(ref first, num2).CompareTo(Unsafe.AddByteOffset(ref second, num2));
1452 }
1453 }
1454 else
1455 {
1456 if (num3 < (nuint)Vector128<byte>.Count)
1457 {
1458 goto IL_021b;
1459 }
1460 num3 -= (nuint)Vector128<byte>.Count;
1461 if (num3 > num2)
1462 {
1464 if (num6 != 65535)
1465 {
1466 goto IL_0111;
1467 }
1468 }
1469 num2 = num3;
1471 if (num6 != 65535)
1472 {
1473 goto IL_0111;
1474 }
1475 }
1476 }
1477 goto IL_0277;
1478 IL_0277:
1479 return firstLength - secondLength;
1480 IL_0273:
1481 for (; num > num2; num2++)
1482 {
1483 int num7 = Unsafe.AddByteOffset(ref first, num2).CompareTo(Unsafe.AddByteOffset(ref second, num2));
1484 if (num7 != 0)
1485 {
1486 return num7;
1487 }
1488 }
1489 goto IL_0277;
1490 IL_021b:
1491 if (num3 > (nuint)sizeof(UIntPtr))
1492 {
1493 for (num3 -= (nuint)sizeof(UIntPtr); num3 > num2 && LoadNUInt(ref first, num2) == LoadNUInt(ref second, num2); num2 += (nuint)sizeof(UIntPtr))
1494 {
1495 }
1496 }
1497 goto IL_0273;
1498 IL_0111:
1499 uint value3 = ~num6;
1501 return Unsafe.AddByteOffset(ref first, num2).CompareTo(Unsafe.AddByteOffset(ref second, num2));
1502 }
1503
1504 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1506 {
1507 Vector<ulong> vector = Vector.AsVectorUInt64(match);
1508 ulong num = 0uL;
1509 int num2 = Vector<ulong>.Count - 1;
1510 for (int i = 0; i < Vector<ulong>.Count; i++)
1511 {
1512 num = vector[num2];
1513 if (num != 0L)
1514 {
1515 break;
1516 }
1517 num2--;
1518 }
1519 return num2 * 8 + LocateLastFoundByte(num);
1520 }
1521
1522 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1523 private static int LocateFirstFoundByte(ulong match)
1524 {
1526 }
1527
1528 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1529 private static int LocateLastFoundByte(ulong match)
1530 {
1531 return BitOperations.Log2(match) >> 3;
1532 }
1533
1534 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1535 private static ushort LoadUShort(ref byte start)
1536 {
1537 return Unsafe.ReadUnaligned<ushort>(ref start);
1538 }
1539
1540 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1541 private static uint LoadUInt(ref byte start)
1542 {
1543 return Unsafe.ReadUnaligned<uint>(ref start);
1544 }
1545
1546 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1547 private static uint LoadUInt(ref byte start, nuint offset)
1548 {
1549 return Unsafe.ReadUnaligned<uint>(ref Unsafe.AddByteOffset(ref start, offset));
1550 }
1551
1552 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1553 private static nuint LoadNUInt(ref byte start)
1554 {
1555 return Unsafe.ReadUnaligned<UIntPtr>(ref start);
1556 }
1557
1558 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1559 private static nuint LoadNUInt(ref byte start, nuint offset)
1560 {
1561 return Unsafe.ReadUnaligned<UIntPtr>(ref Unsafe.AddByteOffset(ref start, offset));
1562 }
1563
1564 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1565 private static Vector<byte> LoadVector(ref byte start, nuint offset)
1566 {
1567 return Unsafe.ReadUnaligned<Vector<byte>>(ref Unsafe.AddByteOffset(ref start, offset));
1568 }
1569
1570 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1571 private static Vector128<byte> LoadVector128(ref byte start, nuint offset)
1572 {
1573 return Unsafe.ReadUnaligned<Vector128<byte>>(ref Unsafe.AddByteOffset(ref start, offset));
1574 }
1575
1576 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1577 private static Vector256<byte> LoadVector256(ref byte start, nuint offset)
1578 {
1579 return Unsafe.ReadUnaligned<Vector256<byte>>(ref Unsafe.AddByteOffset(ref start, offset));
1580 }
1581
1582 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1583 private static nuint GetByteVectorSpanLength(nuint offset, int length)
1584 {
1585 return (uint)((length - (int)offset) & ~(Vector<byte>.Count - 1));
1586 }
1587
1588 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1589 private static nuint GetByteVector128SpanLength(nuint offset, int length)
1590 {
1591 return (uint)((length - (int)offset) & ~(Vector128<byte>.Count - 1));
1592 }
1593
1594 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1595 private static nuint GetByteVector256SpanLength(nuint offset, int length)
1596 {
1597 return (uint)((length - (int)offset) & ~(Vector256<byte>.Count - 1));
1598 }
1599
1600 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1601 private unsafe static nuint UnalignedCountVector(ref byte searchSpace)
1602 {
1603 nint num = (nint)Unsafe.AsPointer(ref searchSpace) & (nint)(Vector<byte>.Count - 1);
1604 return (nuint)((Vector<byte>.Count - num) & (Vector<byte>.Count - 1));
1605 }
1606
1607 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1608 private unsafe static nuint UnalignedCountVector128(ref byte searchSpace)
1609 {
1610 nint num = (nint)Unsafe.AsPointer(ref searchSpace) & (nint)(Vector128<byte>.Count - 1);
1611 return (uint)((Vector128<byte>.Count - num) & (Vector128<byte>.Count - 1));
1612 }
1613
1614 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1615 private unsafe static nuint UnalignedCountVectorFromEnd(ref byte searchSpace, int length)
1616 {
1617 nint num = (nint)Unsafe.AsPointer(ref searchSpace) & (nint)(Vector<byte>.Count - 1);
1618 return (uint)(((length & (Vector<byte>.Count - 1)) + num) & (Vector<byte>.Count - 1));
1619 }
1620
1621 public static int IndexOf(ref char searchSpace, int searchSpaceLength, ref char value, int valueLength)
1622 {
1623 if (valueLength == 0)
1624 {
1625 return 0;
1626 }
1627 char value2 = value;
1628 ref char source = ref Unsafe.Add(ref value, 1);
1629 int num = valueLength - 1;
1630 int num2 = searchSpaceLength - num;
1631 int num3 = 0;
1632 while (num2 > 0)
1633 {
1635 if (num4 == -1)
1636 {
1637 break;
1638 }
1639 num2 -= num4;
1640 num3 += num4;
1641 if (num2 <= 0)
1642 {
1643 break;
1644 }
1645 if (SequenceEqual(ref Unsafe.As<char, byte>(ref Unsafe.Add(ref searchSpace, num3 + 1)), ref Unsafe.As<char, byte>(ref source), (nuint)(uint)num * (nuint)2u))
1646 {
1647 return num3;
1648 }
1649 num2--;
1650 num3++;
1651 }
1652 return -1;
1653 }
1654
1655 [MethodImpl(MethodImplOptions.AggressiveOptimization)]
1656 public unsafe static int SequenceCompareTo(ref char first, int firstLength, ref char second, int secondLength)
1657 {
1658 int result = firstLength - secondLength;
1659 if (!Unsafe.AreSame(ref first, ref second))
1660 {
1661 nuint num = (uint)(((uint)firstLength < (uint)secondLength) ? firstLength : secondLength);
1662 nuint num2 = 0u;
1663 if (num >= (nuint)(sizeof(UIntPtr) / 2))
1664 {
1665 if (Vector.IsHardwareAccelerated && num >= (nuint)Vector<ushort>.Count)
1666 {
1667 nuint num3 = num - (nuint)Vector<ushort>.Count;
1668 while (!(Unsafe.ReadUnaligned<Vector<ushort>>(ref Unsafe.As<char, byte>(ref Unsafe.Add(ref first, (nint)num2))) != Unsafe.ReadUnaligned<Vector<ushort>>(ref Unsafe.As<char, byte>(ref Unsafe.Add(ref second, (nint)num2)))))
1669 {
1670 num2 += (nuint)Vector<ushort>.Count;
1671 if (num3 < num2)
1672 {
1673 break;
1674 }
1675 }
1676 }
1677 for (; num >= (nuint)((nint)num2 + (nint)(sizeof(UIntPtr) / 2)) && Unsafe.ReadUnaligned<UIntPtr>(ref Unsafe.As<char, byte>(ref Unsafe.Add(ref first, (nint)num2))) == Unsafe.ReadUnaligned<UIntPtr>(ref Unsafe.As<char, byte>(ref Unsafe.Add(ref second, (nint)num2))); num2 += (nuint)(sizeof(UIntPtr) / 2))
1678 {
1679 }
1680 }
1681 if (num >= num2 + 2 && Unsafe.ReadUnaligned<int>(ref Unsafe.As<char, byte>(ref Unsafe.Add(ref first, (nint)num2))) == Unsafe.ReadUnaligned<int>(ref Unsafe.As<char, byte>(ref Unsafe.Add(ref second, (nint)num2))))
1682 {
1683 num2 += 2;
1684 }
1685 for (; num2 < num; num2++)
1686 {
1687 int num4 = Unsafe.Add(ref first, (nint)num2).CompareTo(Unsafe.Add(ref second, (nint)num2));
1688 if (num4 != 0)
1689 {
1690 return num4;
1691 }
1692 }
1693 }
1694 return result;
1695 }
1696
1697 [MethodImpl(MethodImplOptions.AggressiveOptimization)]
1698 public unsafe static bool Contains(ref char searchSpace, char value, int length)
1699 {
1700 fixed (char* ptr = &searchSpace)
1701 {
1702 char* ptr2 = ptr;
1703 char* ptr3 = ptr2 + length;
1705 {
1706 int num = ((int)ptr2 & (Unsafe.SizeOf<Vector<ushort>>() - 1)) / 2;
1707 length = (Vector<ushort>.Count - num) & (Vector<ushort>.Count - 1);
1708 }
1709 while (true)
1710 {
1711 if (length >= 4)
1712 {
1713 length -= 4;
1714 if (value == *ptr2 || value == ptr2[1] || value == ptr2[2] || value == ptr2[3])
1715 {
1716 break;
1717 }
1718 ptr2 += 4;
1719 continue;
1720 }
1721 while (length > 0)
1722 {
1723 length--;
1724 if (value == *ptr2)
1725 {
1726 goto end_IL_0079;
1727 }
1728 ptr2++;
1729 }
1731 {
1732 length = (int)((ptr3 - ptr2) & ~(Vector<ushort>.Count - 1));
1734 while (length > 0)
1735 {
1737 if (!Vector<ushort>.Zero.Equals(other))
1738 {
1739 goto end_IL_0079;
1740 }
1743 }
1744 if (ptr2 < ptr3)
1745 {
1746 length = (int)(ptr3 - ptr2);
1747 continue;
1748 }
1749 }
1750 return false;
1751 continue;
1753 break;
1754 }
1755 return true;
1756 }
1757 }
1758
1759 [MethodImpl(MethodImplOptions.AggressiveOptimization)]
1760 public unsafe static int IndexOf(ref char searchSpace, char value, int length)
1761 {
1762 nint num = 0;
1763 nint num2 = length;
1764 if (((int)Unsafe.AsPointer(ref searchSpace) & 1) == 0)
1765 {
1767 {
1768 if (length >= Vector128<ushort>.Count * 2)
1769 {
1771 }
1772 }
1774 {
1776 }
1777 }
1778 while (true)
1779 {
1780 if (num2 >= 4)
1781 {
1782 ref char reference = ref Unsafe.Add(ref searchSpace, num);
1783 if (value == reference)
1784 {
1785 break;
1786 }
1787 if (value != Unsafe.Add(ref reference, 1))
1788 {
1789 if (value != Unsafe.Add(ref reference, 2))
1790 {
1791 if (value != Unsafe.Add(ref reference, 3))
1792 {
1793 num += 4;
1794 num2 -= 4;
1795 continue;
1796 }
1797 return (int)(num + 3);
1798 }
1799 return (int)(num + 2);
1800 }
1801 return (int)(num + 1);
1802 }
1803 while (num2 > 0)
1804 {
1805 if (value == Unsafe.Add(ref searchSpace, num))
1806 {
1807 goto end_IL_0090;
1808 }
1809 num++;
1810 num2--;
1811 }
1812 if (Avx2.IsSupported)
1813 {
1814 if (num < length)
1815 {
1816 if (((nuint)Unsafe.AsPointer(ref Unsafe.Add(ref searchSpace, num)) & (nuint)(Vector256<byte>.Count - 1)) != 0)
1817 {
1820 int num3 = Sse2.MoveMask(Sse2.CompareEqual(left, right).AsByte());
1821 if (num3 != 0)
1822 {
1823 return (int)(num + (uint)BitOperations.TrailingZeroCount(num3) / 2u);
1824 }
1825 num += Vector128<ushort>.Count;
1826 }
1828 if (num2 > 0)
1829 {
1831 do
1832 {
1834 int num4 = Avx2.MoveMask(Avx2.CompareEqual(left2, right2).AsByte());
1835 if (num4 == 0)
1836 {
1837 num += Vector256<ushort>.Count;
1839 continue;
1840 }
1841 return (int)(num + (uint)BitOperations.TrailingZeroCount(num4) / 2u);
1842 }
1843 while (num2 > 0);
1844 }
1846 if (num2 > 0)
1847 {
1850 int num5 = Sse2.MoveMask(Sse2.CompareEqual(left3, right3).AsByte());
1851 if (num5 != 0)
1852 {
1853 return (int)(num + (uint)BitOperations.TrailingZeroCount(num5) / 2u);
1854 }
1855 num += Vector128<ushort>.Count;
1856 }
1857 if (num < length)
1858 {
1859 num2 = length - num;
1860 continue;
1861 }
1862 }
1863 }
1864 else if (Sse2.IsSupported)
1865 {
1866 if (num < length)
1867 {
1869 if (num2 > 0)
1870 {
1872 do
1873 {
1875 int num6 = Sse2.MoveMask(Sse2.CompareEqual(left4, right4).AsByte());
1876 if (num6 == 0)
1877 {
1878 num += Vector128<ushort>.Count;
1880 continue;
1881 }
1882 return (int)(num + (uint)BitOperations.TrailingZeroCount(num6) / 2u);
1883 }
1884 while (num2 > 0);
1885 }
1886 if (num < length)
1887 {
1888 num2 = length - num;
1889 continue;
1890 }
1891 }
1892 }
1893 else
1894 {
1896 {
1897 }
1898 if (Vector.IsHardwareAccelerated && num < length)
1899 {
1901 if (num2 > 0)
1902 {
1904 do
1905 {
1907 if (Vector<ushort>.Zero.Equals(vector))
1908 {
1909 num += Vector<ushort>.Count;
1911 continue;
1912 }
1913 return (int)(num + LocateFirstFoundChar(vector));
1914 }
1915 while (num2 > 0);
1916 }
1917 if (num < length)
1918 {
1919 num2 = length - num;
1920 continue;
1921 }
1922 }
1923 }
1924 return -1;
1925 continue;
1927 break;
1928 }
1929 return (int)num;
1930 }
1931
1932 [MethodImpl(MethodImplOptions.AggressiveOptimization)]
1933 public static int IndexOfAny(ref char searchStart, char value0, char value1, int length)
1934 {
1935 nuint num = 0u;
1936 nuint num2 = (uint)length;
1937 int num4;
1938 if (Sse2.IsSupported)
1939 {
1940 nint num3 = (nint)length - (nint)Vector128<ushort>.Count;
1941 if (num3 >= 0)
1942 {
1943 num2 = (nuint)num3;
1944 if (Sse2.IsSupported)
1945 {
1946 if (Avx2.IsSupported && num2 >= (nuint)Vector128<ushort>.Count)
1947 {
1950 num2 -= (nuint)Vector128<ushort>.Count;
1951 Vector256<ushort> right;
1952 while (num2 > num)
1953 {
1954 right = LoadVector256(ref searchStart, num);
1955 num4 = Avx2.MoveMask(Avx2.Or(Avx2.CompareEqual(left, right), Avx2.CompareEqual(left2, right)).AsByte());
1956 if (num4 == 0)
1957 {
1958 num += (nuint)Vector256<ushort>.Count;
1959 continue;
1960 }
1961 goto IL_0211;
1962 }
1964 num = num2;
1965 num4 = Avx2.MoveMask(Avx2.Or(Avx2.CompareEqual(left, right), Avx2.CompareEqual(left2, right)).AsByte());
1966 if (num4 == 0)
1967 {
1968 goto IL_00c1;
1969 }
1970 }
1971 else
1972 {
1976 while (num2 > num)
1977 {
1980 if (num4 == 0)
1981 {
1982 num += (nuint)Vector128<ushort>.Count;
1983 continue;
1984 }
1985 goto IL_0211;
1986 }
1988 num = num2;
1990 if (num4 == 0)
1991 {
1992 goto IL_00c1;
1993 }
1994 }
1995 goto IL_0211;
1996 }
1997 goto IL_0223;
1998 }
1999 }
2001 {
2002 nint num5 = (nint)length - (nint)Vector<ushort>.Count;
2003 if (num5 >= 0)
2004 {
2005 num2 = (nuint)num5;
2006 goto IL_0223;
2007 }
2008 }
2009 while (num2 >= 4)
2010 {
2011 ref char reference = ref Add(ref searchStart, num);
2012 int num6 = reference;
2013 if (value0 != num6 && value1 != num6)
2014 {
2015 num6 = Unsafe.Add(ref reference, 1);
2016 if (value0 != num6 && value1 != num6)
2017 {
2018 num6 = Unsafe.Add(ref reference, 2);
2019 if (value0 != num6 && value1 != num6)
2020 {
2021 num6 = Unsafe.Add(ref reference, 3);
2022 if (value0 != num6 && value1 != num6)
2023 {
2024 num += 4;
2025 num2 -= 4;
2026 continue;
2027 }
2028 return (int)(num + 3);
2029 }
2030 return (int)(num + 2);
2031 }
2032 return (int)(num + 1);
2033 }
2034 goto IL_00d5;
2035 }
2036 while (num2 != 0)
2037 {
2038 int num6 = Add(ref searchStart, num);
2039 if (value0 != num6 && value1 != num6)
2040 {
2041 num++;
2042 num2--;
2043 continue;
2044 }
2045 goto IL_00d5;
2046 }
2047 goto IL_00c1;
2048 IL_02c3:
2050 num += (uint)LocateFirstFoundChar(vector);
2051 goto IL_00d5;
2052 IL_00d5:
2053 return (int)num;
2054 IL_00c1:
2055 return -1;
2056 IL_0211:
2057 num += (nuint)(uint)BitOperations.TrailingZeroCount(num4) >> 1;
2058 goto IL_00d5;
2059 IL_0223:
2061 {
2064 while (num2 > num)
2065 {
2068 if (Vector<ushort>.Zero.Equals(vector))
2069 {
2070 num += (nuint)Vector<ushort>.Count;
2071 continue;
2072 }
2073 goto IL_02c3;
2074 }
2076 num = num2;
2078 if (!Vector<ushort>.Zero.Equals(vector))
2079 {
2080 goto IL_02c3;
2081 }
2082 }
2083 goto IL_00c1;
2084 }
2085
2086 [MethodImpl(MethodImplOptions.AggressiveOptimization)]
2087 public static int IndexOfAny(ref char searchStart, char value0, char value1, char value2, int length)
2088 {
2089 nuint num = 0u;
2090 nuint num2 = (uint)length;
2091 int num4;
2092 if (Sse2.IsSupported)
2093 {
2094 nint num3 = (nint)length - (nint)Vector128<ushort>.Count;
2095 if (num3 >= 0)
2096 {
2097 num2 = (nuint)num3;
2098 if (Sse2.IsSupported)
2099 {
2100 if (Avx2.IsSupported && num2 >= (nuint)Vector128<ushort>.Count)
2101 {
2105 num2 -= (nuint)Vector128<ushort>.Count;
2106 Vector256<ushort> right;
2107 while (num2 > num)
2108 {
2109 right = LoadVector256(ref searchStart, num);
2110 num4 = Avx2.MoveMask(Avx2.Or(Avx2.Or(Avx2.CompareEqual(left, right), Avx2.CompareEqual(left2, right)), Avx2.CompareEqual(left3, right)).AsByte());
2111 if (num4 == 0)
2112 {
2113 num += (nuint)Vector256<ushort>.Count;
2114 continue;
2115 }
2116 goto IL_027f;
2117 }
2119 num = num2;
2120 num4 = Avx2.MoveMask(Avx2.Or(Avx2.Or(Avx2.CompareEqual(left, right), Avx2.CompareEqual(left2, right)), Avx2.CompareEqual(left3, right)).AsByte());
2121 if (num4 == 0)
2122 {
2123 goto IL_00e7;
2124 }
2125 }
2126 else
2127 {
2132 while (num2 > num)
2133 {
2136 if (num4 == 0)
2137 {
2138 num += (nuint)Vector128<ushort>.Count;
2139 continue;
2140 }
2141 goto IL_027f;
2142 }
2144 num = num2;
2146 if (num4 == 0)
2147 {
2148 goto IL_00e7;
2149 }
2150 }
2151 goto IL_027f;
2152 }
2153 goto IL_0291;
2154 }
2155 }
2157 {
2158 nint num5 = (nint)length - (nint)Vector<ushort>.Count;
2159 if (num5 >= 0)
2160 {
2161 num2 = (nuint)num5;
2162 goto IL_0291;
2163 }
2164 }
2165 while (num2 >= 4)
2166 {
2167 ref char reference = ref Add(ref searchStart, num);
2168 int num6 = reference;
2169 if (value0 != num6 && value1 != num6 && value2 != num6)
2170 {
2171 num6 = Unsafe.Add(ref reference, 1);
2172 if (value0 != num6 && value1 != num6 && value2 != num6)
2173 {
2174 num6 = Unsafe.Add(ref reference, 2);
2175 if (value0 != num6 && value1 != num6 && value2 != num6)
2176 {
2177 num6 = Unsafe.Add(ref reference, 3);
2178 if (value0 != num6 && value1 != num6 && value2 != num6)
2179 {
2180 num += 4;
2181 num2 -= 4;
2182 continue;
2183 }
2184 return (int)(num + 3);
2185 }
2186 return (int)(num + 2);
2187 }
2188 return (int)(num + 1);
2189 }
2190 goto IL_00fb;
2191 }
2192 while (num2 != 0)
2193 {
2194 int num6 = Add(ref searchStart, num);
2195 if (value0 != num6 && value1 != num6 && value2 != num6)
2196 {
2197 num++;
2198 num2--;
2199 continue;
2200 }
2201 goto IL_00fb;
2202 }
2203 goto IL_00e7;
2204 IL_00e7:
2205 return -1;
2206 IL_00fb:
2207 return (int)num;
2208 IL_0355:
2210 num += (uint)LocateFirstFoundChar(vector);
2211 goto IL_00fb;
2212 IL_0291:
2214 {
2218 while (num2 > num)
2219 {
2222 if (Vector<ushort>.Zero.Equals(vector))
2223 {
2224 num += (nuint)Vector<ushort>.Count;
2225 continue;
2226 }
2227 goto IL_0355;
2228 }
2230 num = num2;
2232 if (!Vector<ushort>.Zero.Equals(vector))
2233 {
2234 goto IL_0355;
2235 }
2236 }
2237 goto IL_00e7;
2238 IL_027f:
2239 num += (nuint)(uint)BitOperations.TrailingZeroCount(num4) >> 1;
2240 goto IL_00fb;
2241 }
2242
2243 [MethodImpl(MethodImplOptions.AggressiveOptimization)]
2244 public static int IndexOfAny(ref char searchStart, char value0, char value1, char value2, char value3, int length)
2245 {
2246 nuint num = 0u;
2247 nuint num2 = (uint)length;
2248 int num4;
2249 if (Sse2.IsSupported)
2250 {
2251 nint num3 = (nint)length - (nint)Vector128<ushort>.Count;
2252 if (num3 >= 0)
2253 {
2254 num2 = (nuint)num3;
2255 if (Sse2.IsSupported)
2256 {
2257 if (Avx2.IsSupported && num2 >= (nuint)Vector128<ushort>.Count)
2258 {
2263 num2 -= (nuint)Vector128<ushort>.Count;
2264 Vector256<ushort> right;
2265 while (num2 > num)
2266 {
2267 right = LoadVector256(ref searchStart, num);
2268 num4 = Avx2.MoveMask(Avx2.CompareEqual(left, right).AsByte());
2269 num4 |= Avx2.MoveMask(Avx2.CompareEqual(left2, right).AsByte());
2270 num4 |= Avx2.MoveMask(Avx2.CompareEqual(left3, right).AsByte());
2271 num4 |= Avx2.MoveMask(Avx2.CompareEqual(left4, right).AsByte());
2272 if (num4 == 0)
2273 {
2274 num += (nuint)Vector256<ushort>.Count;
2275 continue;
2276 }
2277 goto IL_036f;
2278 }
2280 num = num2;
2281 num4 = Avx2.MoveMask(Avx2.CompareEqual(left, right).AsByte());
2282 num4 |= Avx2.MoveMask(Avx2.CompareEqual(left2, right).AsByte());
2283 num4 |= Avx2.MoveMask(Avx2.CompareEqual(left3, right).AsByte());
2284 num4 |= Avx2.MoveMask(Avx2.CompareEqual(left4, right).AsByte());
2285 if (num4 == 0)
2286 {
2287 goto IL_0115;
2288 }
2289 }
2290 else
2291 {
2297 while (num2 > num)
2298 {
2304 if (num4 == 0)
2305 {
2306 num += (nuint)Vector128<ushort>.Count;
2307 continue;
2308 }
2309 goto IL_036f;
2310 }
2312 num = num2;
2317 if (num4 == 0)
2318 {
2319 goto IL_0115;
2320 }
2321 }
2322 goto IL_036f;
2323 }
2324 goto IL_0381;
2325 }
2326 }
2328 {
2329 nint num5 = (nint)length - (nint)Vector<ushort>.Count;
2330 if (num5 >= 0)
2331 {
2332 num2 = (nuint)num5;
2333 goto IL_0381;
2334 }
2335 }
2336 while (num2 >= 4)
2337 {
2338 ref char reference = ref Add(ref searchStart, num);
2339 int num6 = reference;
2340 if (value0 != num6 && value1 != num6 && value2 != num6 && value3 != num6)
2341 {
2342 num6 = Unsafe.Add(ref reference, 1);
2343 if (value0 != num6 && value1 != num6 && value2 != num6 && value3 != num6)
2344 {
2345 num6 = Unsafe.Add(ref reference, 2);
2346 if (value0 != num6 && value1 != num6 && value2 != num6 && value3 != num6)
2347 {
2348 num6 = Unsafe.Add(ref reference, 3);
2349 if (value0 != num6 && value1 != num6 && value2 != num6 && value3 != num6)
2350 {
2351 num += 4;
2352 num2 -= 4;
2353 continue;
2354 }
2355 return (int)(num + 3);
2356 }
2357 return (int)(num + 2);
2358 }
2359 return (int)(num + 1);
2360 }
2361 goto IL_0129;
2362 }
2363 while (num2 != 0)
2364 {
2365 int num6 = Add(ref searchStart, num);
2366 if (value0 != num6 && value1 != num6 && value2 != num6 && value3 != num6)
2367 {
2368 num++;
2369 num2--;
2370 continue;
2371 }
2372 goto IL_0129;
2373 }
2374 goto IL_0115;
2375 IL_0129:
2376 return (int)num;
2377 IL_0115:
2378 return -1;
2379 IL_046a:
2381 num += (uint)LocateFirstFoundChar(vector);
2382 goto IL_0129;
2383 IL_036f:
2384 num += (nuint)(uint)BitOperations.TrailingZeroCount(num4) >> 1;
2385 goto IL_0129;
2386 IL_0381:
2388 {
2393 while (num2 > num)
2394 {
2397 if (Vector<ushort>.Zero.Equals(vector))
2398 {
2399 num += (nuint)Vector<ushort>.Count;
2400 continue;
2401 }
2402 goto IL_046a;
2403 }
2405 num = num2;
2407 if (!Vector<ushort>.Zero.Equals(vector))
2408 {
2409 goto IL_046a;
2410 }
2411 }
2412 goto IL_0115;
2413 }
2414
2415 [MethodImpl(MethodImplOptions.AggressiveOptimization)]
2416 public static int IndexOfAny(ref char searchStart, char value0, char value1, char value2, char value3, char value4, int length)
2417 {
2418 nuint num = 0u;
2419 nuint num2 = (uint)length;
2420 int num4;
2421 if (Sse2.IsSupported)
2422 {
2423 nint num3 = (nint)length - (nint)Vector128<ushort>.Count;
2424 if (num3 >= 0)
2425 {
2426 num2 = (nuint)num3;
2427 if (Sse2.IsSupported)
2428 {
2429 if (Avx2.IsSupported && num2 >= (nuint)Vector128<ushort>.Count)
2430 {
2436 num2 -= (nuint)Vector128<ushort>.Count;
2437 Vector256<ushort> right;
2438 while (num2 > num)
2439 {
2440 right = LoadVector256(ref searchStart, num);
2441 num4 = Avx2.MoveMask(Avx2.CompareEqual(left, right).AsByte());
2442 num4 |= Avx2.MoveMask(Avx2.CompareEqual(left2, right).AsByte());
2443 num4 |= Avx2.MoveMask(Avx2.CompareEqual(left3, right).AsByte());
2444 num4 |= Avx2.MoveMask(Avx2.CompareEqual(left4, right).AsByte());
2445 num4 |= Avx2.MoveMask(Avx2.CompareEqual(left5, right).AsByte());
2446 if (num4 == 0)
2447 {
2448 num += (nuint)Vector256<ushort>.Count;
2449 continue;
2450 }
2451 goto IL_040f;
2452 }
2454 num = num2;
2455 num4 = Avx2.MoveMask(Avx2.CompareEqual(left, right).AsByte());
2456 num4 |= Avx2.MoveMask(Avx2.CompareEqual(left2, right).AsByte());
2457 num4 |= Avx2.MoveMask(Avx2.CompareEqual(left3, right).AsByte());
2458 num4 |= Avx2.MoveMask(Avx2.CompareEqual(left4, right).AsByte());
2459 num4 |= Avx2.MoveMask(Avx2.CompareEqual(left5, right).AsByte());
2460 if (num4 == 0)
2461 {
2462 goto IL_0134;
2463 }
2464 }
2465 else
2466 {
2473 while (num2 > num)
2474 {
2481 if (num4 == 0)
2482 {
2483 num += (nuint)Vector128<ushort>.Count;
2484 continue;
2485 }
2486 goto IL_040f;
2487 }
2489 num = num2;
2495 if (num4 == 0)
2496 {
2497 goto IL_0134;
2498 }
2499 }
2500 goto IL_040f;
2501 }
2502 goto IL_0421;
2503 }
2504 }
2506 {
2507 nint num5 = (nint)length - (nint)Vector<ushort>.Count;
2508 if (num5 >= 0)
2509 {
2510 num2 = (nuint)num5;
2511 goto IL_0421;
2512 }
2513 }
2514 while (num2 >= 4)
2515 {
2516 ref char reference = ref Add(ref searchStart, num);
2517 int num6 = reference;
2518 if (value0 != num6 && value1 != num6 && value2 != num6 && value3 != num6 && value4 != num6)
2519 {
2520 num6 = Unsafe.Add(ref reference, 1);
2521 if (value0 != num6 && value1 != num6 && value2 != num6 && value3 != num6 && value4 != num6)
2522 {
2523 num6 = Unsafe.Add(ref reference, 2);
2524 if (value0 != num6 && value1 != num6 && value2 != num6 && value3 != num6 && value4 != num6)
2525 {
2526 num6 = Unsafe.Add(ref reference, 3);
2527 if (value0 != num6 && value1 != num6 && value2 != num6 && value3 != num6 && value4 != num6)
2528 {
2529 num += 4;
2530 num2 -= 4;
2531 continue;
2532 }
2533 return (int)(num + 3);
2534 }
2535 return (int)(num + 2);
2536 }
2537 return (int)(num + 1);
2538 }
2539 goto IL_0148;
2540 }
2541 while (num2 != 0)
2542 {
2543 int num6 = Add(ref searchStart, num);
2544 if (value0 != num6 && value1 != num6 && value2 != num6 && value3 != num6 && value4 != num6)
2545 {
2546 num++;
2547 num2--;
2548 continue;
2549 }
2550 goto IL_0148;
2551 }
2552 goto IL_0134;
2553 IL_0148:
2554 return (int)num;
2555 IL_052f:
2557 num += (uint)LocateFirstFoundChar(vector);
2558 goto IL_0148;
2559 IL_0421:
2561 {
2567 while (num2 > num)
2568 {
2571 if (Vector<ushort>.Zero.Equals(vector))
2572 {
2573 num += (nuint)Vector<ushort>.Count;
2574 continue;
2575 }
2576 goto IL_052f;
2577 }
2579 num = num2;
2581 if (!Vector<ushort>.Zero.Equals(vector))
2582 {
2583 goto IL_052f;
2584 }
2585 }
2586 goto IL_0134;
2587 IL_0134:
2588 return -1;
2589 IL_040f:
2590 num += (nuint)(uint)BitOperations.TrailingZeroCount(num4) >> 1;
2591 goto IL_0148;
2592 }
2593
2594 [MethodImpl(MethodImplOptions.AggressiveOptimization)]
2595 public unsafe static int LastIndexOf(ref char searchSpace, char value, int length)
2596 {
2597 fixed (char* ptr = &searchSpace)
2598 {
2599 char* ptr2 = ptr + length;
2600 char* ptr3 = ptr;
2602 {
2603 length = ((int)ptr2 & (Unsafe.SizeOf<Vector<ushort>>() - 1)) / 2;
2604 }
2605 while (true)
2606 {
2607 if (length >= 4)
2608 {
2609 length -= 4;
2610 ptr2 -= 4;
2611 if (ptr2[3] == value)
2612 {
2613 break;
2614 }
2615 if (ptr2[2] != value)
2616 {
2617 if (ptr2[1] != value)
2618 {
2619 if (*ptr2 != value)
2620 {
2621 continue;
2622 }
2623 goto IL_011d;
2624 }
2625 return (int)(ptr2 - ptr3) + 1;
2626 }
2627 return (int)(ptr2 - ptr3) + 2;
2628 }
2629 while (length > 0)
2630 {
2631 length--;
2632 ptr2--;
2633 if (*ptr2 != value)
2634 {
2635 continue;
2636 }
2637 goto IL_011d;
2638 }
2640 {
2641 length = (int)((ptr2 - ptr3) & ~(Vector<ushort>.Count - 1));
2643 while (length > 0)
2644 {
2645 char* ptr4 = ptr2 - Vector<ushort>.Count;
2647 if (Vector<ushort>.Zero.Equals(vector))
2648 {
2651 continue;
2652 }
2653 return (int)(ptr4 - ptr3) + LocateLastFoundChar(vector);
2654 }
2655 if (ptr2 > ptr3)
2656 {
2657 length = (int)(ptr2 - ptr3);
2658 continue;
2659 }
2660 }
2661 return -1;
2662 IL_011d:
2663 return (int)(ptr2 - ptr3);
2664 }
2665 return (int)(ptr2 - ptr3) + 3;
2666 }
2667 }
2668
2669 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2671 {
2672 Vector<ulong> vector = Vector.AsVectorUInt64(match);
2673 ulong num = 0uL;
2674 int i;
2675 for (i = 0; i < Vector<ulong>.Count; i++)
2676 {
2677 num = vector[i];
2678 if (num != 0L)
2679 {
2680 break;
2681 }
2682 }
2683 return i * 4 + LocateFirstFoundChar(num);
2684 }
2685
2686 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2687 private static int LocateFirstFoundChar(ulong match)
2688 {
2690 }
2691
2692 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2694 {
2695 Vector<ulong> vector = Vector.AsVectorUInt64(match);
2696 ulong num = 0uL;
2697 int num2 = Vector<ulong>.Count - 1;
2698 for (int i = 0; i < Vector<ulong>.Count; i++)
2699 {
2700 num = vector[num2];
2701 if (num != 0L)
2702 {
2703 break;
2704 }
2705 num2--;
2706 }
2707 return num2 * 4 + LocateLastFoundChar(num);
2708 }
2709
2710 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2711 private static int LocateLastFoundChar(ulong match)
2712 {
2713 return BitOperations.Log2(match) >> 4;
2714 }
2715
2716 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2717 private static Vector<ushort> LoadVector(ref char start, nint offset)
2718 {
2719 return Unsafe.ReadUnaligned<Vector<ushort>>(ref Unsafe.As<char, byte>(ref Unsafe.Add(ref start, offset)));
2720 }
2721
2722 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2723 private static Vector<ushort> LoadVector(ref char start, nuint offset)
2724 {
2725 return Unsafe.ReadUnaligned<Vector<ushort>>(ref Unsafe.As<char, byte>(ref Unsafe.Add(ref start, (nint)offset)));
2726 }
2727
2728 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2730 {
2731 return Unsafe.ReadUnaligned<Vector128<ushort>>(ref Unsafe.As<char, byte>(ref Unsafe.Add(ref start, offset)));
2732 }
2733
2734 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2735 private static Vector128<ushort> LoadVector128(ref char start, nuint offset)
2736 {
2737 return Unsafe.ReadUnaligned<Vector128<ushort>>(ref Unsafe.As<char, byte>(ref Unsafe.Add(ref start, (nint)offset)));
2738 }
2739
2740 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2742 {
2743 return Unsafe.ReadUnaligned<Vector256<ushort>>(ref Unsafe.As<char, byte>(ref Unsafe.Add(ref start, offset)));
2744 }
2745
2746 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2747 private static Vector256<ushort> LoadVector256(ref char start, nuint offset)
2748 {
2749 return Unsafe.ReadUnaligned<Vector256<ushort>>(ref Unsafe.As<char, byte>(ref Unsafe.Add(ref start, (nint)offset)));
2750 }
2751
2752 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2753 private static ref char Add(ref char start, nuint offset)
2754 {
2755 return ref Unsafe.Add(ref start, (nint)offset);
2756 }
2757
2758 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2759 private static nint GetCharVectorSpanLength(nint offset, nint length)
2760 {
2761 return (length - offset) & ~(Vector<ushort>.Count - 1);
2762 }
2763
2764 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2765 private static nint GetCharVector128SpanLength(nint offset, nint length)
2766 {
2767 return (length - offset) & ~(Vector128<ushort>.Count - 1);
2768 }
2769
2770 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2771 private static nint GetCharVector256SpanLength(nint offset, nint length)
2772 {
2773 return (length - offset) & ~(Vector256<ushort>.Count - 1);
2774 }
2775
2776 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2777 private unsafe static nint UnalignedCountVector(ref char searchSpace)
2778 {
2779 return (nint)(uint)(-(int)Unsafe.AsPointer(ref searchSpace) / 2) & (nint)(Vector<ushort>.Count - 1);
2780 }
2781
2782 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2783 private unsafe static nint UnalignedCountVector128(ref char searchSpace)
2784 {
2785 return (nint)(uint)(-(int)Unsafe.AsPointer(ref searchSpace) / 2) & (nint)(Vector128<ushort>.Count - 1);
2786 }
2787
2788 public static void ClearWithoutReferences(ref byte b, nuint byteLength)
2789 {
2790 if (byteLength != 0)
2791 {
2792 if (byteLength <= 768)
2793 {
2795 }
2796 else
2797 {
2799 }
2800 }
2801 }
2802
2804 {
2805 while (pointerSizeLength >= 8)
2806 {
2807 Unsafe.Add(ref Unsafe.Add(ref ip, (nint)pointerSizeLength), -1) = default(IntPtr);
2808 Unsafe.Add(ref Unsafe.Add(ref ip, (nint)pointerSizeLength), -2) = default(IntPtr);
2809 Unsafe.Add(ref Unsafe.Add(ref ip, (nint)pointerSizeLength), -3) = default(IntPtr);
2810 Unsafe.Add(ref Unsafe.Add(ref ip, (nint)pointerSizeLength), -4) = default(IntPtr);
2811 Unsafe.Add(ref Unsafe.Add(ref ip, (nint)pointerSizeLength), -5) = default(IntPtr);
2812 Unsafe.Add(ref Unsafe.Add(ref ip, (nint)pointerSizeLength), -6) = default(IntPtr);
2813 Unsafe.Add(ref Unsafe.Add(ref ip, (nint)pointerSizeLength), -7) = default(IntPtr);
2814 Unsafe.Add(ref Unsafe.Add(ref ip, (nint)pointerSizeLength), -8) = default(IntPtr);
2815 pointerSizeLength -= 8;
2816 }
2817 if (pointerSizeLength < 4)
2818 {
2819 if (pointerSizeLength < 2)
2820 {
2821 if (pointerSizeLength == 0)
2822 {
2823 return;
2824 }
2825 goto IL_012f;
2826 }
2827 }
2828 else
2829 {
2830 Unsafe.Add(ref ip, 2) = default(IntPtr);
2831 Unsafe.Add(ref ip, 3) = default(IntPtr);
2832 Unsafe.Add(ref Unsafe.Add(ref ip, (nint)pointerSizeLength), -3) = default(IntPtr);
2833 Unsafe.Add(ref Unsafe.Add(ref ip, (nint)pointerSizeLength), -2) = default(IntPtr);
2834 }
2835 Unsafe.Add(ref ip, 1) = default(IntPtr);
2836 Unsafe.Add(ref Unsafe.Add(ref ip, (nint)pointerSizeLength), -1) = default(IntPtr);
2837 goto IL_012f;
2838 IL_012f:
2839 ip = default(IntPtr);
2840 }
2841
2842 public static void Fill<T>(ref T refData, nuint numElements, T value)
2843 {
2844 if (!RuntimeHelpers.IsReferenceOrContainsReferences<T>() && Vector.IsHardwareAccelerated && Unsafe.SizeOf<T>() <= Vector<byte>.Count && BitOperations.IsPow2(Unsafe.SizeOf<T>()) && numElements >= (uint)(Vector<byte>.Count / Unsafe.SizeOf<T>()))
2845 {
2846 T source = value;
2848 if (Unsafe.SizeOf<T>() == 1)
2849 {
2850 value2 = new Vector<byte>(Unsafe.As<T, byte>(ref source));
2851 }
2852 else if (Unsafe.SizeOf<T>() == 2)
2853 {
2854 value2 = (Vector<byte>)new Vector<ushort>(Unsafe.As<T, ushort>(ref source));
2855 }
2856 else if (Unsafe.SizeOf<T>() == 4)
2857 {
2858 value2 = ((typeof(T) == typeof(float)) ? ((Vector<byte>)new Vector<float>((float)(object)source)) : ((Vector<byte>)new Vector<uint>(Unsafe.As<T, uint>(ref source))));
2859 }
2860 else if (Unsafe.SizeOf<T>() == 8)
2861 {
2862 value2 = ((typeof(T) == typeof(double)) ? ((Vector<byte>)new Vector<double>((double)(object)source)) : ((Vector<byte>)new Vector<ulong>(Unsafe.As<T, ulong>(ref source))));
2863 }
2864 else if (Unsafe.SizeOf<T>() == 16)
2865 {
2867 if (Vector<byte>.Count == 16)
2868 {
2869 value2 = vector.AsVector();
2870 }
2871 else
2872 {
2873 if (Vector<byte>.Count != 32)
2874 {
2875 goto IL_022e;
2876 }
2877 value2 = Vector256.Create(vector, vector).AsVector();
2878 }
2879 }
2880 else
2881 {
2882 if (Unsafe.SizeOf<T>() != 32 || Vector<byte>.Count != 32)
2883 {
2884 goto IL_022e;
2885 }
2886 value2 = Unsafe.As<T, Vector256<byte>>(ref source).AsVector();
2887 }
2888 ref byte source2 = ref Unsafe.As<T, byte>(ref refData);
2889 nuint num = numElements * (nuint)Unsafe.SizeOf<T>();
2890 nuint num2 = num & (nuint)(2 * -Vector<byte>.Count);
2891 nuint num3 = 0u;
2892 if (numElements >= (uint)(2 * Vector<byte>.Count / Unsafe.SizeOf<T>()))
2893 {
2894 do
2895 {
2896 Unsafe.WriteUnaligned(ref Unsafe.AddByteOffset(ref source2, num3), value2);
2897 Unsafe.WriteUnaligned(ref Unsafe.AddByteOffset(ref source2, num3 + (nuint)Vector<byte>.Count), value2);
2898 num3 += (uint)(2 * Vector<byte>.Count);
2899 }
2900 while (num3 < num2);
2901 }
2902 if ((num & (nuint)Vector<byte>.Count) != 0)
2903 {
2904 Unsafe.WriteUnaligned(ref Unsafe.AddByteOffset(ref source2, num3), value2);
2905 }
2906 Unsafe.WriteUnaligned(ref Unsafe.AddByteOffset(ref source2, num - (nuint)Vector<byte>.Count), value2);
2907 return;
2908 }
2909 goto IL_022e;
2910 IL_022e:
2911 nuint num4 = 0u;
2912 if (numElements >= 8)
2913 {
2914 nuint num5 = numElements & ~(nuint)7u;
2915 do
2916 {
2917 Unsafe.Add(ref refData, (nint)(num4 + 0)) = value;
2918 Unsafe.Add(ref refData, (nint)(num4 + 1)) = value;
2919 Unsafe.Add(ref refData, (nint)(num4 + 2)) = value;
2920 Unsafe.Add(ref refData, (nint)(num4 + 3)) = value;
2921 Unsafe.Add(ref refData, (nint)(num4 + 4)) = value;
2922 Unsafe.Add(ref refData, (nint)(num4 + 5)) = value;
2923 Unsafe.Add(ref refData, (nint)(num4 + 6)) = value;
2924 Unsafe.Add(ref refData, (nint)(num4 + 7)) = value;
2925 }
2926 while ((num4 += 8) < num5);
2927 }
2928 if ((numElements & 4) != 0)
2929 {
2930 Unsafe.Add(ref refData, (nint)(num4 + 0)) = value;
2931 Unsafe.Add(ref refData, (nint)(num4 + 1)) = value;
2932 Unsafe.Add(ref refData, (nint)(num4 + 2)) = value;
2933 Unsafe.Add(ref refData, (nint)(num4 + 3)) = value;
2934 num4 += 4;
2935 }
2936 if ((numElements & 2) != 0)
2937 {
2938 Unsafe.Add(ref refData, (nint)(num4 + 0)) = value;
2939 Unsafe.Add(ref refData, (nint)(num4 + 1)) = value;
2940 num4 += 2;
2941 }
2942 if ((numElements & 1) != 0)
2943 {
2944 Unsafe.Add(ref refData, (nint)num4) = value;
2945 }
2946 }
2947
2949 {
2950 if (valueLength == 0)
2951 {
2952 return 0;
2953 }
2954 T value2 = value;
2955 ref T second = ref Unsafe.Add(ref value, 1);
2956 int num = valueLength - 1;
2957 int num2 = 0;
2958 while (true)
2959 {
2960 int num3 = searchSpaceLength - num2 - num;
2961 if (num3 <= 0)
2962 {
2963 break;
2964 }
2966 if (num4 == -1)
2967 {
2968 break;
2969 }
2970 num2 += num4;
2971 if (SequenceEqual(ref Unsafe.Add(ref searchSpace, num2 + 1), ref second, num))
2972 {
2973 return num2;
2974 }
2975 num2++;
2976 }
2977 return -1;
2978 }
2979
2980 public static bool Contains<T>(ref T searchSpace, T value, int length) where T : IEquatable<T>
2981 {
2982 nint num = 0;
2983 if (default(T) != null || value != null)
2984 {
2985 while (length >= 8)
2986 {
2987 length -= 8;
2988 if (!value.Equals(Unsafe.Add(ref searchSpace, num + 0)) && !value.Equals(Unsafe.Add(ref searchSpace, num + 1)) && !value.Equals(Unsafe.Add(ref searchSpace, num + 2)) && !value.Equals(Unsafe.Add(ref searchSpace, num + 3)) && !value.Equals(Unsafe.Add(ref searchSpace, num + 4)) && !value.Equals(Unsafe.Add(ref searchSpace, num + 5)) && !value.Equals(Unsafe.Add(ref searchSpace, num + 6)) && !value.Equals(Unsafe.Add(ref searchSpace, num + 7)))
2989 {
2990 num += 8;
2991 continue;
2992 }
2993 goto IL_0220;
2994 }
2995 if (length >= 4)
2996 {
2997 length -= 4;
2998 if (value.Equals(Unsafe.Add(ref searchSpace, num + 0)) || value.Equals(Unsafe.Add(ref searchSpace, num + 1)) || value.Equals(Unsafe.Add(ref searchSpace, num + 2)) || value.Equals(Unsafe.Add(ref searchSpace, num + 3)))
2999 {
3000 goto IL_0220;
3001 }
3002 num += 4;
3003 }
3004 while (length > 0)
3005 {
3006 length--;
3007 if (!value.Equals(Unsafe.Add(ref searchSpace, num)))
3008 {
3009 num++;
3010 continue;
3011 }
3012 goto IL_0220;
3013 }
3014 }
3015 else
3016 {
3017 nint num2 = length;
3018 num = 0;
3019 while (num < num2)
3020 {
3021 if (Unsafe.Add(ref searchSpace, num) != null)
3022 {
3023 num++;
3024 continue;
3025 }
3026 goto IL_0220;
3027 }
3028 }
3029 return false;
3030 IL_0220:
3031 return true;
3032 }
3033
3035 {
3036 nint num = 0;
3037 if (default(T) != null || value != null)
3038 {
3039 while (length >= 8)
3040 {
3041 length -= 8;
3042 if (value.Equals(Unsafe.Add(ref searchSpace, num)))
3043 {
3044 goto IL_021a;
3045 }
3046 if (value.Equals(Unsafe.Add(ref searchSpace, num + 1)))
3047 {
3048 goto IL_021d;
3049 }
3050 if (value.Equals(Unsafe.Add(ref searchSpace, num + 2)))
3051 {
3052 goto IL_0223;
3053 }
3054 if (!value.Equals(Unsafe.Add(ref searchSpace, num + 3)))
3055 {
3056 if (!value.Equals(Unsafe.Add(ref searchSpace, num + 4)))
3057 {
3058 if (!value.Equals(Unsafe.Add(ref searchSpace, num + 5)))
3059 {
3060 if (!value.Equals(Unsafe.Add(ref searchSpace, num + 6)))
3061 {
3062 if (!value.Equals(Unsafe.Add(ref searchSpace, num + 7)))
3063 {
3064 num += 8;
3065 continue;
3066 }
3067 return (int)(num + 7);
3068 }
3069 return (int)(num + 6);
3070 }
3071 return (int)(num + 5);
3072 }
3073 return (int)(num + 4);
3074 }
3075 goto IL_0229;
3076 }
3077 if (length >= 4)
3078 {
3079 length -= 4;
3080 if (value.Equals(Unsafe.Add(ref searchSpace, num)))
3081 {
3082 goto IL_021a;
3083 }
3084 if (value.Equals(Unsafe.Add(ref searchSpace, num + 1)))
3085 {
3086 goto IL_021d;
3087 }
3088 if (value.Equals(Unsafe.Add(ref searchSpace, num + 2)))
3089 {
3090 goto IL_0223;
3091 }
3092 if (value.Equals(Unsafe.Add(ref searchSpace, num + 3)))
3093 {
3094 goto IL_0229;
3095 }
3096 num += 4;
3097 }
3098 while (length > 0)
3099 {
3100 if (!value.Equals(Unsafe.Add(ref searchSpace, num)))
3101 {
3102 num++;
3103 length--;
3104 continue;
3105 }
3106 goto IL_021a;
3107 }
3108 }
3109 else
3110 {
3111 nint num2 = length;
3112 num = 0;
3113 while (num < num2)
3114 {
3115 if (Unsafe.Add(ref searchSpace, num) != null)
3116 {
3117 num++;
3118 continue;
3119 }
3120 goto IL_021a;
3121 }
3122 }
3123 return -1;
3124 IL_021a:
3125 return (int)num;
3126 IL_021d:
3127 return (int)(num + 1);
3128 IL_0229:
3129 return (int)(num + 3);
3130 IL_0223:
3131 return (int)(num + 2);
3132 }
3133
3135 {
3136 int i = 0;
3137 if (default(T) != null || (value0 != null && value1 != null))
3138 {
3139 while (length - i >= 8)
3140 {
3141 T other = Unsafe.Add(ref searchSpace, i);
3142 if (value0.Equals(other) || value1.Equals(other))
3143 {
3144 goto IL_0350;
3145 }
3146 other = Unsafe.Add(ref searchSpace, i + 1);
3147 if (value0.Equals(other) || value1.Equals(other))
3148 {
3149 goto IL_0352;
3150 }
3151 other = Unsafe.Add(ref searchSpace, i + 2);
3152 if (value0.Equals(other) || value1.Equals(other))
3153 {
3154 goto IL_0356;
3155 }
3156 other = Unsafe.Add(ref searchSpace, i + 3);
3157 if (!value0.Equals(other) && !value1.Equals(other))
3158 {
3159 other = Unsafe.Add(ref searchSpace, i + 4);
3160 if (!value0.Equals(other) && !value1.Equals(other))
3161 {
3162 other = Unsafe.Add(ref searchSpace, i + 5);
3163 if (!value0.Equals(other) && !value1.Equals(other))
3164 {
3165 other = Unsafe.Add(ref searchSpace, i + 6);
3166 if (!value0.Equals(other) && !value1.Equals(other))
3167 {
3168 other = Unsafe.Add(ref searchSpace, i + 7);
3169 if (!value0.Equals(other) && !value1.Equals(other))
3170 {
3171 i += 8;
3172 continue;
3173 }
3174 return i + 7;
3175 }
3176 return i + 6;
3177 }
3178 return i + 5;
3179 }
3180 return i + 4;
3181 }
3182 goto IL_035a;
3183 }
3184 if (length - i >= 4)
3185 {
3186 T other = Unsafe.Add(ref searchSpace, i);
3187 if (value0.Equals(other) || value1.Equals(other))
3188 {
3189 goto IL_0350;
3190 }
3191 other = Unsafe.Add(ref searchSpace, i + 1);
3192 if (value0.Equals(other) || value1.Equals(other))
3193 {
3194 goto IL_0352;
3195 }
3196 other = Unsafe.Add(ref searchSpace, i + 2);
3197 if (value0.Equals(other) || value1.Equals(other))
3198 {
3199 goto IL_0356;
3200 }
3201 other = Unsafe.Add(ref searchSpace, i + 3);
3202 if (value0.Equals(other) || value1.Equals(other))
3203 {
3204 goto IL_035a;
3205 }
3206 i += 4;
3207 }
3208 while (i < length)
3209 {
3210 T other = Unsafe.Add(ref searchSpace, i);
3211 if (!value0.Equals(other) && !value1.Equals(other))
3212 {
3213 i++;
3214 continue;
3215 }
3216 goto IL_0350;
3217 }
3218 }
3219 else
3220 {
3221 for (i = 0; i < length; i++)
3222 {
3223 T other = Unsafe.Add(ref searchSpace, i);
3224 if (other == null)
3225 {
3226 if (value0 != null && value1 != null)
3227 {
3228 continue;
3229 }
3230 }
3231 else if (!other.Equals(value0) && !other.Equals(value1))
3232 {
3233 continue;
3234 }
3235 goto IL_0350;
3236 }
3237 }
3238 return -1;
3239 IL_0352:
3240 return i + 1;
3241 IL_0350:
3242 return i;
3243 IL_0356:
3244 return i + 2;
3245 IL_035a:
3246 return i + 3;
3247 }
3248
3250 {
3251 int i = 0;
3252 if (default(T) != null || (value0 != null && value1 != null && value2 != null))
3253 {
3254 while (length - i >= 8)
3255 {
3256 T other = Unsafe.Add(ref searchSpace, i);
3257 if (value0.Equals(other) || value1.Equals(other) || value2.Equals(other))
3258 {
3259 goto IL_0471;
3260 }
3261 other = Unsafe.Add(ref searchSpace, i + 1);
3262 if (value0.Equals(other) || value1.Equals(other) || value2.Equals(other))
3263 {
3264 goto IL_0473;
3265 }
3266 other = Unsafe.Add(ref searchSpace, i + 2);
3267 if (value0.Equals(other) || value1.Equals(other) || value2.Equals(other))
3268 {
3269 goto IL_0477;
3270 }
3271 other = Unsafe.Add(ref searchSpace, i + 3);
3272 if (!value0.Equals(other) && !value1.Equals(other) && !value2.Equals(other))
3273 {
3274 other = Unsafe.Add(ref searchSpace, i + 4);
3275 if (!value0.Equals(other) && !value1.Equals(other) && !value2.Equals(other))
3276 {
3277 other = Unsafe.Add(ref searchSpace, i + 5);
3278 if (!value0.Equals(other) && !value1.Equals(other) && !value2.Equals(other))
3279 {
3280 other = Unsafe.Add(ref searchSpace, i + 6);
3281 if (!value0.Equals(other) && !value1.Equals(other) && !value2.Equals(other))
3282 {
3283 other = Unsafe.Add(ref searchSpace, i + 7);
3284 if (!value0.Equals(other) && !value1.Equals(other) && !value2.Equals(other))
3285 {
3286 i += 8;
3287 continue;
3288 }
3289 return i + 7;
3290 }
3291 return i + 6;
3292 }
3293 return i + 5;
3294 }
3295 return i + 4;
3296 }
3297 goto IL_047b;
3298 }
3299 if (length - i >= 4)
3300 {
3301 T other = Unsafe.Add(ref searchSpace, i);
3302 if (value0.Equals(other) || value1.Equals(other) || value2.Equals(other))
3303 {
3304 goto IL_0471;
3305 }
3306 other = Unsafe.Add(ref searchSpace, i + 1);
3307 if (value0.Equals(other) || value1.Equals(other) || value2.Equals(other))
3308 {
3309 goto IL_0473;
3310 }
3311 other = Unsafe.Add(ref searchSpace, i + 2);
3312 if (value0.Equals(other) || value1.Equals(other) || value2.Equals(other))
3313 {
3314 goto IL_0477;
3315 }
3316 other = Unsafe.Add(ref searchSpace, i + 3);
3317 if (value0.Equals(other) || value1.Equals(other) || value2.Equals(other))
3318 {
3319 goto IL_047b;
3320 }
3321 i += 4;
3322 }
3323 while (i < length)
3324 {
3325 T other = Unsafe.Add(ref searchSpace, i);
3326 if (!value0.Equals(other) && !value1.Equals(other) && !value2.Equals(other))
3327 {
3328 i++;
3329 continue;
3330 }
3331 goto IL_0471;
3332 }
3333 }
3334 else
3335 {
3336 for (i = 0; i < length; i++)
3337 {
3338 T other = Unsafe.Add(ref searchSpace, i);
3339 if (other == null)
3340 {
3341 if (value0 != null && value1 != null && value2 != null)
3342 {
3343 continue;
3344 }
3345 }
3346 else if (!other.Equals(value0) && !other.Equals(value1) && !other.Equals(value2))
3347 {
3348 continue;
3349 }
3350 goto IL_0471;
3351 }
3352 }
3353 return -1;
3354 IL_0473:
3355 return i + 1;
3356 IL_047b:
3357 return i + 3;
3358 IL_0471:
3359 return i;
3360 IL_0477:
3361 return i + 2;
3362 }
3363
3365 {
3366 if (valueLength == 0)
3367 {
3368 return -1;
3369 }
3370 if (typeof(T).IsValueType)
3371 {
3372 for (int i = 0; i < searchSpaceLength; i++)
3373 {
3374 T other = Unsafe.Add(ref searchSpace, i);
3375 for (int j = 0; j < valueLength; j++)
3376 {
3377 if (Unsafe.Add(ref value, j).Equals(other))
3378 {
3379 return i;
3380 }
3381 }
3382 }
3383 }
3384 else
3385 {
3386 for (int k = 0; k < searchSpaceLength; k++)
3387 {
3388 T val = Unsafe.Add(ref searchSpace, k);
3389 if (val != null)
3390 {
3391 for (int l = 0; l < valueLength; l++)
3392 {
3393 if (val.Equals(Unsafe.Add(ref value, l)))
3394 {
3395 return k;
3396 }
3397 }
3398 continue;
3399 }
3400 for (int m = 0; m < valueLength; m++)
3401 {
3402 if (Unsafe.Add(ref value, m) == null)
3403 {
3404 return k;
3405 }
3406 }
3407 }
3408 }
3409 return -1;
3410 }
3411
3413 {
3414 if (valueLength == 0)
3415 {
3416 return searchSpaceLength;
3417 }
3418 T value2 = value;
3419 ref T second = ref Unsafe.Add(ref value, 1);
3420 int num = valueLength - 1;
3421 int num2 = 0;
3422 while (true)
3423 {
3424 int num3 = searchSpaceLength - num2 - num;
3425 if (num3 <= 0)
3426 {
3427 break;
3428 }
3430 if (num4 == -1)
3431 {
3432 break;
3433 }
3434 if (SequenceEqual(ref Unsafe.Add(ref searchSpace, num4 + 1), ref second, num))
3435 {
3436 return num4;
3437 }
3438 num2 += num3 - num4;
3439 }
3440 return -1;
3441 }
3442
3444 {
3445 if (default(T) != null || value != null)
3446 {
3447 while (length >= 8)
3448 {
3449 length -= 8;
3450 if (!value.Equals(Unsafe.Add(ref searchSpace, length + 7)))
3451 {
3452 if (!value.Equals(Unsafe.Add(ref searchSpace, length + 6)))
3453 {
3454 if (!value.Equals(Unsafe.Add(ref searchSpace, length + 5)))
3455 {
3456 if (!value.Equals(Unsafe.Add(ref searchSpace, length + 4)))
3457 {
3458 if (!value.Equals(Unsafe.Add(ref searchSpace, length + 3)))
3459 {
3460 if (!value.Equals(Unsafe.Add(ref searchSpace, length + 2)))
3461 {
3462 if (!value.Equals(Unsafe.Add(ref searchSpace, length + 1)))
3463 {
3464 if (!value.Equals(Unsafe.Add(ref searchSpace, length)))
3465 {
3466 continue;
3467 }
3468 goto IL_01fe;
3469 }
3470 goto IL_0200;
3471 }
3472 goto IL_0204;
3473 }
3474 goto IL_0208;
3475 }
3476 return length + 4;
3477 }
3478 return length + 5;
3479 }
3480 return length + 6;
3481 }
3482 return length + 7;
3483 }
3484 if (length >= 4)
3485 {
3486 length -= 4;
3487 if (value.Equals(Unsafe.Add(ref searchSpace, length + 3)))
3488 {
3489 goto IL_0208;
3490 }
3491 if (value.Equals(Unsafe.Add(ref searchSpace, length + 2)))
3492 {
3493 goto IL_0204;
3494 }
3495 if (value.Equals(Unsafe.Add(ref searchSpace, length + 1)))
3496 {
3497 goto IL_0200;
3498 }
3499 if (value.Equals(Unsafe.Add(ref searchSpace, length)))
3500 {
3501 goto IL_01fe;
3502 }
3503 }
3504 while (length > 0)
3505 {
3506 length--;
3507 if (!value.Equals(Unsafe.Add(ref searchSpace, length)))
3508 {
3509 continue;
3510 }
3511 goto IL_01fe;
3512 }
3513 }
3514 else
3515 {
3516 length--;
3517 while (length >= 0)
3518 {
3519 if (Unsafe.Add(ref searchSpace, length) != null)
3520 {
3521 length--;
3522 continue;
3523 }
3524 goto IL_01fe;
3525 }
3526 }
3527 return -1;
3528 IL_0208:
3529 return length + 3;
3530 IL_0200:
3531 return length + 1;
3532 IL_01fe:
3533 return length;
3534 IL_0204:
3535 return length + 2;
3536 }
3537
3539 {
3540 if (default(T) != null || (value0 != null && value1 != null))
3541 {
3542 while (length >= 8)
3543 {
3544 length -= 8;
3545 T other = Unsafe.Add(ref searchSpace, length + 7);
3546 if (!value0.Equals(other) && !value1.Equals(other))
3547 {
3548 other = Unsafe.Add(ref searchSpace, length + 6);
3549 if (!value0.Equals(other) && !value1.Equals(other))
3550 {
3551 other = Unsafe.Add(ref searchSpace, length + 5);
3552 if (!value0.Equals(other) && !value1.Equals(other))
3553 {
3554 other = Unsafe.Add(ref searchSpace, length + 4);
3555 if (!value0.Equals(other) && !value1.Equals(other))
3556 {
3557 other = Unsafe.Add(ref searchSpace, length + 3);
3558 if (!value0.Equals(other) && !value1.Equals(other))
3559 {
3560 other = Unsafe.Add(ref searchSpace, length + 2);
3561 if (!value0.Equals(other) && !value1.Equals(other))
3562 {
3563 other = Unsafe.Add(ref searchSpace, length + 1);
3564 if (!value0.Equals(other) && !value1.Equals(other))
3565 {
3567 if (!value0.Equals(other) && !value1.Equals(other))
3568 {
3569 continue;
3570 }
3571 goto IL_0351;
3572 }
3573 goto IL_0353;
3574 }
3575 goto IL_0357;
3576 }
3577 goto IL_035b;
3578 }
3579 return length + 4;
3580 }
3581 return length + 5;
3582 }
3583 return length + 6;
3584 }
3585 return length + 7;
3586 }
3587 if (length >= 4)
3588 {
3589 length -= 4;
3590 T other = Unsafe.Add(ref searchSpace, length + 3);
3591 if (value0.Equals(other) || value1.Equals(other))
3592 {
3593 goto IL_035b;
3594 }
3595 other = Unsafe.Add(ref searchSpace, length + 2);
3596 if (value0.Equals(other) || value1.Equals(other))
3597 {
3598 goto IL_0357;
3599 }
3600 other = Unsafe.Add(ref searchSpace, length + 1);
3601 if (value0.Equals(other) || value1.Equals(other))
3602 {
3603 goto IL_0353;
3604 }
3606 if (value0.Equals(other) || value1.Equals(other))
3607 {
3608 goto IL_0351;
3609 }
3610 }
3611 while (length > 0)
3612 {
3613 length--;
3614 T other = Unsafe.Add(ref searchSpace, length);
3615 if (!value0.Equals(other) && !value1.Equals(other))
3616 {
3617 continue;
3618 }
3619 goto IL_0351;
3620 }
3621 }
3622 else
3623 {
3624 for (length--; length >= 0; length--)
3625 {
3626 T other = Unsafe.Add(ref searchSpace, length);
3627 if (other == null)
3628 {
3629 if (value0 != null && value1 != null)
3630 {
3631 continue;
3632 }
3633 }
3634 else if (!other.Equals(value0) && !other.Equals(value1))
3635 {
3636 continue;
3637 }
3638 goto IL_0351;
3639 }
3640 }
3641 return -1;
3642 IL_035b:
3643 return length + 3;
3644 IL_0357:
3645 return length + 2;
3646 IL_0351:
3647 return length;
3648 IL_0353:
3649 return length + 1;
3650 }
3651
3653 {
3654 if (default(T) != null || (value0 != null && value1 != null))
3655 {
3656 while (length >= 8)
3657 {
3658 length -= 8;
3659 T other = Unsafe.Add(ref searchSpace, length + 7);
3660 if (!value0.Equals(other) && !value1.Equals(other) && !value2.Equals(other))
3661 {
3662 other = Unsafe.Add(ref searchSpace, length + 6);
3663 if (!value0.Equals(other) && !value1.Equals(other) && !value2.Equals(other))
3664 {
3665 other = Unsafe.Add(ref searchSpace, length + 5);
3666 if (!value0.Equals(other) && !value1.Equals(other) && !value2.Equals(other))
3667 {
3668 other = Unsafe.Add(ref searchSpace, length + 4);
3669 if (!value0.Equals(other) && !value1.Equals(other) && !value2.Equals(other))
3670 {
3671 other = Unsafe.Add(ref searchSpace, length + 3);
3672 if (!value0.Equals(other) && !value1.Equals(other) && !value2.Equals(other))
3673 {
3674 other = Unsafe.Add(ref searchSpace, length + 2);
3675 if (!value0.Equals(other) && !value1.Equals(other) && !value2.Equals(other))
3676 {
3677 other = Unsafe.Add(ref searchSpace, length + 1);
3678 if (!value0.Equals(other) && !value1.Equals(other) && !value2.Equals(other))
3679 {
3681 if (!value0.Equals(other) && !value1.Equals(other) && !value2.Equals(other))
3682 {
3683 continue;
3684 }
3685 goto IL_047a;
3686 }
3687 goto IL_047d;
3688 }
3689 goto IL_0482;
3690 }
3691 goto IL_0487;
3692 }
3693 return length + 4;
3694 }
3695 return length + 5;
3696 }
3697 return length + 6;
3698 }
3699 return length + 7;
3700 }
3701 if (length >= 4)
3702 {
3703 length -= 4;
3704 T other = Unsafe.Add(ref searchSpace, length + 3);
3705 if (value0.Equals(other) || value1.Equals(other) || value2.Equals(other))
3706 {
3707 goto IL_0487;
3708 }
3709 other = Unsafe.Add(ref searchSpace, length + 2);
3710 if (value0.Equals(other) || value1.Equals(other) || value2.Equals(other))
3711 {
3712 goto IL_0482;
3713 }
3714 other = Unsafe.Add(ref searchSpace, length + 1);
3715 if (value0.Equals(other) || value1.Equals(other) || value2.Equals(other))
3716 {
3717 goto IL_047d;
3718 }
3720 if (value0.Equals(other) || value1.Equals(other) || value2.Equals(other))
3721 {
3722 goto IL_047a;
3723 }
3724 }
3725 while (length > 0)
3726 {
3727 length--;
3728 T other = Unsafe.Add(ref searchSpace, length);
3729 if (!value0.Equals(other) && !value1.Equals(other) && !value2.Equals(other))
3730 {
3731 continue;
3732 }
3733 goto IL_047a;
3734 }
3735 }
3736 else
3737 {
3738 for (length--; length >= 0; length--)
3739 {
3740 T other = Unsafe.Add(ref searchSpace, length);
3741 if (other == null)
3742 {
3743 if (value0 != null && value1 != null && value2 != null)
3744 {
3745 continue;
3746 }
3747 }
3748 else if (!other.Equals(value0) && !other.Equals(value1) && !other.Equals(value2))
3749 {
3750 continue;
3751 }
3752 goto IL_047a;
3753 }
3754 }
3755 return -1;
3756 IL_0482:
3757 return length + 2;
3758 IL_047d:
3759 return length + 1;
3760 IL_0487:
3761 return length + 3;
3762 IL_047a:
3763 return length;
3764 }
3765
3767 {
3768 if (valueLength == 0)
3769 {
3770 return -1;
3771 }
3772 if (typeof(T).IsValueType)
3773 {
3774 for (int num = searchSpaceLength - 1; num >= 0; num--)
3775 {
3776 T other = Unsafe.Add(ref searchSpace, num);
3777 for (int i = 0; i < valueLength; i++)
3778 {
3779 if (Unsafe.Add(ref value, i).Equals(other))
3780 {
3781 return num;
3782 }
3783 }
3784 }
3785 }
3786 else
3787 {
3788 for (int num2 = searchSpaceLength - 1; num2 >= 0; num2--)
3789 {
3790 T val = Unsafe.Add(ref searchSpace, num2);
3791 if (val != null)
3792 {
3793 for (int j = 0; j < valueLength; j++)
3794 {
3795 if (val.Equals(Unsafe.Add(ref value, j)))
3796 {
3797 return num2;
3798 }
3799 }
3800 }
3801 else
3802 {
3803 for (int k = 0; k < valueLength; k++)
3804 {
3805 if (Unsafe.Add(ref value, k) == null)
3806 {
3807 return num2;
3808 }
3809 }
3810 }
3811 }
3812 }
3813 return -1;
3814 }
3815
3816 public static bool SequenceEqual<T>(ref T first, ref T second, int length) where T : IEquatable<T>
3817 {
3818 if (!Unsafe.AreSame(ref first, ref second))
3819 {
3820 nint num = 0;
3821 while (true)
3822 {
3823 if (length >= 8)
3824 {
3825 length -= 8;
3826 T val = Unsafe.Add(ref first, num);
3827 T val2 = Unsafe.Add(ref second, num);
3828 if (val?.Equals(val2) ?? (val2 == null))
3829 {
3830 val = Unsafe.Add(ref first, num + 1);
3831 val2 = Unsafe.Add(ref second, num + 1);
3832 if (val?.Equals(val2) ?? (val2 == null))
3833 {
3834 val = Unsafe.Add(ref first, num + 2);
3835 val2 = Unsafe.Add(ref second, num + 2);
3836 if (val?.Equals(val2) ?? (val2 == null))
3837 {
3838 val = Unsafe.Add(ref first, num + 3);
3839 val2 = Unsafe.Add(ref second, num + 3);
3840 if (val?.Equals(val2) ?? (val2 == null))
3841 {
3842 val = Unsafe.Add(ref first, num + 4);
3843 val2 = Unsafe.Add(ref second, num + 4);
3844 if (val?.Equals(val2) ?? (val2 == null))
3845 {
3846 val = Unsafe.Add(ref first, num + 5);
3847 val2 = Unsafe.Add(ref second, num + 5);
3848 if (val?.Equals(val2) ?? (val2 == null))
3849 {
3850 val = Unsafe.Add(ref first, num + 6);
3851 val2 = Unsafe.Add(ref second, num + 6);
3852 if (val?.Equals(val2) ?? (val2 == null))
3853 {
3854 val = Unsafe.Add(ref first, num + 7);
3855 val2 = Unsafe.Add(ref second, num + 7);
3856 if (val?.Equals(val2) ?? (val2 == null))
3857 {
3858 num += 8;
3859 continue;
3860 }
3861 }
3862 }
3863 }
3864 }
3865 }
3866 }
3867 }
3868 }
3869 else
3870 {
3871 if (length < 4)
3872 {
3873 goto IL_03b8;
3874 }
3875 length -= 4;
3876 T val = Unsafe.Add(ref first, num);
3877 T val2 = Unsafe.Add(ref second, num);
3878 if (val?.Equals(val2) ?? (val2 == null))
3879 {
3880 val = Unsafe.Add(ref first, num + 1);
3881 val2 = Unsafe.Add(ref second, num + 1);
3882 if (val?.Equals(val2) ?? (val2 == null))
3883 {
3884 val = Unsafe.Add(ref first, num + 2);
3885 val2 = Unsafe.Add(ref second, num + 2);
3886 if (val?.Equals(val2) ?? (val2 == null))
3887 {
3888 val = Unsafe.Add(ref first, num + 3);
3889 val2 = Unsafe.Add(ref second, num + 3);
3890 if (val?.Equals(val2) ?? (val2 == null))
3891 {
3892 num += 4;
3893 goto IL_03b8;
3894 }
3895 }
3896 }
3897 }
3898 }
3899 goto IL_03be;
3900 IL_03b8:
3901 while (length > 0)
3902 {
3903 T val = Unsafe.Add(ref first, num);
3904 T val2 = Unsafe.Add(ref second, num);
3905 if (val?.Equals(val2) ?? (val2 == null))
3906 {
3907 num++;
3908 length--;
3909 continue;
3910 }
3911 goto IL_03be;
3912 }
3913 break;
3914 IL_03be:
3915 return false;
3916 }
3917 }
3918 return true;
3919 }
3920
3921 public static int SequenceCompareTo<T>(ref T first, int firstLength, ref T second, int secondLength) where T : IComparable<T>
3922 {
3923 int num = firstLength;
3924 if (num > secondLength)
3925 {
3926 num = secondLength;
3927 }
3928 for (int i = 0; i < num; i++)
3929 {
3930 T val = Unsafe.Add(ref second, i);
3931 int num2 = Unsafe.Add(ref first, i)?.CompareTo(val) ?? ((val != null) ? (-1) : 0);
3932 if (num2 != 0)
3933 {
3934 return num2;
3935 }
3936 }
3937 return firstLength.CompareTo(secondLength);
3938 }
3939}
static void InitBlockUnaligned(ref byte startAddress, byte value, uint byteCount)
Definition Unsafe.cs:107
static unsafe void _ZeroMemory(ref byte b, nuint byteLength)
Definition Buffer.cs:20
static int TrailingZeroCount(int value)
static bool IsPow2(int value)
static int Log2(uint value)
static bool IsHardwareAccelerated
Definition Vector.cs:14
static Vector< int > Equals(Vector< float > left, Vector< float > right)
Definition Vector.cs:52
static Vector128< byte > Create(byte value)
Definition Vector128.cs:138
static Vector256< byte > Create(byte value)
Definition Vector256.cs:105
static int MoveMask(Vector256< sbyte > value)
Definition Avx2.cs:1578
static Vector256< sbyte > CompareEqual(Vector256< sbyte > left, Vector256< sbyte > right)
Definition Avx2.cs:512
static new bool IsSupported
Definition Avx2.cs:15
static Vector256< sbyte > Or(Vector256< sbyte > left, Vector256< sbyte > right)
Definition Avx2.cs:1638
static int MoveMask(Vector128< sbyte > value)
Definition Sse2.cs:772
static Vector128< sbyte > CompareEqual(Vector128< sbyte > left, Vector128< sbyte > right)
Definition Sse2.cs:232
static Vector128< byte > Or(Vector128< byte > left, Vector128< byte > right)
Definition Sse2.cs:837
static new bool IsSupported
Definition Sse2.cs:60
static int IndexOfAny(ref char searchStart, char value0, char value1, int length)
static nint GetCharVector128SpanLength(nint offset, nint length)
static int LocateLastFoundChar(Vector< ushort > match)
static Vector256< ushort > LoadVector256(ref char start, nuint offset)
static unsafe nint UnalignedCountVector128(ref char searchSpace)
static bool Contains(ref byte searchSpace, byte value, int length)
static int IndexOf(ref char searchSpace, int searchSpaceLength, ref char value, int valueLength)
static void ClearWithReferences(ref IntPtr ip, nuint pointerSizeLength)
static unsafe int LastIndexOf(ref char searchSpace, char value, int length)
static int BinarySearch< T, TComparable >(this ReadOnlySpan< T > span, TComparable comparable)
static int LastIndexOfAny(ref byte searchSpace, byte value0, byte value1, int length)
static unsafe nint UnalignedCountVector(ref char searchSpace)
static unsafe nuint UnalignedCountVector(ref byte searchSpace)
static Vector< ushort > LoadVector(ref char start, nuint offset)
static nint GetCharVector256SpanLength(nint offset, nint length)
static Vector< byte > LoadVector(ref byte start, nuint offset)
static Vector128< ushort > LoadVector128(ref char start, nuint offset)
static nint GetCharVectorSpanLength(nint offset, nint length)
static int IndexOfAny(ref char searchStart, char value0, char value1, char value2, char value3, int length)
static Vector128< byte > LoadVector128(ref byte start, nuint offset)
static int IndexOf< T >(ref T searchSpace, int searchSpaceLength, ref T value, int valueLength)
static unsafe int SequenceCompareTo(ref char first, int firstLength, ref char second, int secondLength)
static int LastIndexOfAny< T >(ref T searchSpace, T value0, T value1, int length)
static int LastIndexOf(ref byte searchSpace, byte value, int length)
static int LocateFirstFoundChar(Vector< ushort > match)
static bool SequenceEqual< T >(ref T first, ref T second, int length)
static void ClearWithoutReferences(ref byte b, nuint byteLength)
static int SequenceCompareTo< T >(ref T first, int firstLength, ref T second, int secondLength)
static int LocateLastFoundByte(Vector< byte > match)
static int LocateLastFoundByte(ulong match)
static ref char Add(ref char start, nuint offset)
static unsafe int IndexOf(ref char searchSpace, char value, int length)
static int LocateLastFoundChar(ulong match)
static Vector128< ushort > LoadVector128(ref char start, nint offset)
static int IndexOf(ref byte searchSpace, int searchSpaceLength, ref byte value, int valueLength)
static int LastIndexOf< T >(ref T searchSpace, int searchSpaceLength, ref T value, int valueLength)
static unsafe bool Contains(ref char searchSpace, char value, int length)
static ushort LoadUShort(ref byte start)
static void Fill< T >(ref T refData, nuint numElements, T value)
static Vector256< ushort > LoadVector256(ref char start, nint offset)
static int IndexOfAny< T >(ref T searchSpace, T value0, T value1, int length)
static unsafe int IndexOf(ref byte searchSpace, byte value, int length)
static nuint GetByteVector256SpanLength(nuint offset, int length)
static nuint GetByteVector128SpanLength(nuint offset, int length)
static bool Contains< T >(ref T searchSpace, T value, int length)
static unsafe int SequenceCompareTo(ref byte first, int firstLength, ref byte second, int secondLength)
static uint LoadUInt(ref byte start, nuint offset)
static int LocateFirstFoundByte(Vector< byte > match)
static nuint LoadNUInt(ref byte start)
static Vector< ushort > LoadVector(ref char start, nint offset)
static uint LoadUInt(ref byte start)
static int IndexOfAny(ref byte searchSpace, byte value0, byte value1, int length)
static nuint GetByteVectorSpanLength(nuint offset, int length)
static unsafe bool SequenceEqual(ref byte first, ref byte second, nuint length)
static Vector256< byte > LoadVector256(ref byte start, nuint offset)
static nuint LoadNUInt(ref byte start, nuint offset)
static int IndexOfAny(ref char searchStart, char value0, char value1, char value2, char value3, char value4, int length)
static unsafe nuint UnalignedCountVector128(ref byte searchSpace)
static int IndexOfAny(ref byte searchSpace, byte value0, byte value1, byte value2, int length)
static int IndexOfAny(ref char searchStart, char value0, char value1, char value2, int length)
static int LastIndexOfAny(ref byte searchSpace, byte value0, byte value1, byte value2, int length)
static int LocateFirstFoundChar(ulong match)
static int LastIndexOf(ref byte searchSpace, int searchSpaceLength, ref byte value, int valueLength)
static int LocateFirstFoundByte(ulong match)
static unsafe nuint UnalignedCountVectorFromEnd(ref byte searchSpace, int length)
static void ThrowArgumentNullException(string name)
ComparerComparable(T value, TComparer comparer)