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

◆ SequenceCompareTo() [2/2]

static unsafe int System.SpanHelpers.SequenceCompareTo ( ref char first,
int firstLength,
ref char second,
int secondLength )
inlinestatic

Definition at line 1656 of file SpanHelpers.cs.

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 }
static bool IsHardwareAccelerated
Definition Vector.cs:14

References System.Collections.Generic.Dictionary< TKey, TValue >.Count, and System.Numerics.Vector< T >.IsHardwareAccelerated.