Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ LastIndexOf() [1/3]

static int System.SpanHelpers.LastIndexOf ( ref byte searchSpace,
byte value,
int length )
inlinestatic

Definition at line 395 of file SpanHelpers.cs.

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 }
static bool IsHardwareAccelerated
Definition Vector.cs:14
static Vector< int > Equals(Vector< float > left, Vector< float > right)
Definition Vector.cs:52
static Vector< byte > LoadVector(ref byte start, nuint offset)
static int LocateLastFoundByte(Vector< byte > match)
static unsafe nuint UnalignedCountVectorFromEnd(ref byte searchSpace, int length)

References System.Collections.Generic.Dictionary< TKey, TValue >.Count, System.Numerics.Vector< T >.Equals(), System.Numerics.Vector< T >.IsHardwareAccelerated, System.length, System.SpanHelpers.LoadVector(), System.SpanHelpers.LocateLastFoundByte(), System.SpanHelpers.UnalignedCountVectorFromEnd(), and System.value.