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

◆ IndexOfAny() [5/6]

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

Definition at line 2087 of file SpanHelpers.cs.

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 }
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().