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

◆ IndexOfAny() [6/6]

static int System.SpanHelpers.IndexOfAny ( ref char searchStart,
char value0,
char value1,
int length )
inlinestatic

Definition at line 1933 of file SpanHelpers.cs.

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 }
static int TrailingZeroCount(int 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 Vector< byte > LoadVector(ref byte start, nuint offset)
static Vector128< byte > LoadVector128(ref byte start, nuint offset)
static int LocateFirstFoundChar(Vector< ushort > match)
static Vector256< byte > LoadVector256(ref byte start, nuint offset)

References System.Add, System.Runtime.Intrinsics.X86.Sse2.CompareEqual(), System.Runtime.Intrinsics.X86.Avx2.CompareEqual(), System.Collections.Generic.Dictionary< TKey, TValue >.Count, System.Runtime.Intrinsics.Vector128< T >.Create(), System.Runtime.Intrinsics.Vector256< T >.Create(), System.Numerics.Vector< T >.Equals(), System.Numerics.Vector< T >.IsHardwareAccelerated, System.Runtime.Intrinsics.X86.Avx2.IsSupported, System.Runtime.Intrinsics.X86.Sse2.IsSupported, System.length, System.SpanHelpers.LoadVector(), System.SpanHelpers.LoadVector128(), System.SpanHelpers.LoadVector256(), System.SpanHelpers.LocateFirstFoundChar(), System.Runtime.Intrinsics.X86.Sse2.MoveMask(), System.Runtime.Intrinsics.X86.Avx2.MoveMask(), System.Runtime.Intrinsics.X86.Sse2.Or(), System.Runtime.Intrinsics.X86.Avx2.Or(), and System.Numerics.BitOperations.TrailingZeroCount().