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

◆ LastIndexOfIgnoreCase()

static unsafe int System.Globalization.InvariantModeCasing.LastIndexOfIgnoreCase ( ReadOnlySpan< char > source,
ReadOnlySpan< char > value )
inlinestaticpackage

Definition at line 243 of file InvariantModeCasing.cs.

244 {
245 fixed (char* ptr3 = &MemoryMarshal.GetReference(source))
246 {
247 fixed (char* ptr = &MemoryMarshal.GetReference(value))
248 {
249 char* ptr2 = ptr + value.Length - 1;
250 for (char* ptr4 = ptr3 + (source.Length - value.Length); ptr4 >= ptr3; ptr4--)
251 {
252 char* ptr5 = ptr;
253 char* ptr6 = ptr4;
254 while (ptr5 <= ptr2)
255 {
256 if (!char.IsHighSurrogate(*ptr5) || ptr5 == ptr2)
257 {
258 if (*ptr5 != *ptr6 && ToUpper(*ptr5) != ToUpper(*ptr6))
259 {
260 break;
261 }
262 ptr5++;
263 ptr6++;
264 }
265 else if (char.IsHighSurrogate(*ptr6) && char.IsLowSurrogate(ptr6[1]) && char.IsLowSurrogate(ptr5[1]))
266 {
267 if (!SurrogateCasing.Equal(*ptr6, ptr6[1], *ptr5, ptr5[1]))
268 {
269 break;
270 }
271 ptr6 += 2;
272 ptr5 += 2;
273 }
274 else
275 {
276 if (*ptr5 != *ptr6)
277 {
278 break;
279 }
280 ptr6++;
281 ptr5++;
282 }
283 }
284 if (ptr5 > ptr2)
285 {
286 return (int)(ptr4 - ptr3);
287 }
288 }
289 return -1;
290 }
291 }
292 }

References System.Globalization.SurrogateCasing.Equal(), System.source, System.Globalization.InvariantModeCasing.ToUpper(), and System.value.

Referenced by System.Globalization.Ordinal.LastIndexOfOrdinalIgnoreCase().