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

◆ LastIndexOfAny() [1/2]

static int System.SpanHelpers.LastIndexOfAny ( ref byte searchSpace,
byte value0,
byte value1,
byte value2,
int length )
inlinestatic

Definition at line 1061 of file SpanHelpers.cs.

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 }
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(), and System.SpanHelpers.UnalignedCountVectorFromEnd().