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

◆ SequenceCompareTo() [1/2]

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

Definition at line 1370 of file SpanHelpers.cs.

1371 {
1372 nuint num;
1373 uint num6;
1374 nuint num3;
1375 nuint num2;
1376 if (!Unsafe.AreSame(ref first, ref second))
1377 {
1378 num = (uint)(((uint)firstLength < (uint)secondLength) ? firstLength : secondLength);
1379 num2 = 0u;
1380 num3 = num;
1381 if (!Avx2.IsSupported)
1382 {
1383 if (Sse2.IsSupported)
1384 {
1385 if (num3 >= (nuint)Vector128<byte>.Count)
1386 {
1387 num3 -= (nuint)Vector128<byte>.Count;
1388 while (true)
1389 {
1390 uint num4;
1391 if (num3 > num2)
1392 {
1394 if (num4 == 65535)
1395 {
1396 num2 += (nuint)Vector128<byte>.Count;
1397 continue;
1398 }
1399 }
1400 else
1401 {
1402 num2 = num3;
1404 if (num4 == 65535)
1405 {
1406 break;
1407 }
1408 }
1409 uint value = ~num4;
1411 return Unsafe.AddByteOffset(ref first, num2).CompareTo(Unsafe.AddByteOffset(ref second, num2));
1412 }
1413 goto IL_0277;
1414 }
1415 }
1416 else if (Vector.IsHardwareAccelerated && num3 > (nuint)Vector<byte>.Count)
1417 {
1418 for (num3 -= (nuint)Vector<byte>.Count; num3 > num2 && !(LoadVector(ref first, num2) != LoadVector(ref second, num2)); num2 += (nuint)Vector<byte>.Count)
1419 {
1420 }
1421 goto IL_0273;
1422 }
1423 goto IL_021b;
1424 }
1425 if (num3 >= (nuint)Vector256<byte>.Count)
1426 {
1427 num3 -= (nuint)Vector256<byte>.Count;
1428 while (true)
1429 {
1430 uint num5;
1431 if (num3 > num2)
1432 {
1434 if (num5 == uint.MaxValue)
1435 {
1436 num2 += (nuint)Vector256<byte>.Count;
1437 continue;
1438 }
1439 }
1440 else
1441 {
1442 num2 = num3;
1444 if (num5 == uint.MaxValue)
1445 {
1446 break;
1447 }
1448 }
1449 uint value2 = ~num5;
1451 return Unsafe.AddByteOffset(ref first, num2).CompareTo(Unsafe.AddByteOffset(ref second, num2));
1452 }
1453 }
1454 else
1455 {
1456 if (num3 < (nuint)Vector128<byte>.Count)
1457 {
1458 goto IL_021b;
1459 }
1460 num3 -= (nuint)Vector128<byte>.Count;
1461 if (num3 > num2)
1462 {
1464 if (num6 != 65535)
1465 {
1466 goto IL_0111;
1467 }
1468 }
1469 num2 = num3;
1471 if (num6 != 65535)
1472 {
1473 goto IL_0111;
1474 }
1475 }
1476 }
1477 goto IL_0277;
1478 IL_0277:
1479 return firstLength - secondLength;
1480 IL_0273:
1481 for (; num > num2; num2++)
1482 {
1483 int num7 = Unsafe.AddByteOffset(ref first, num2).CompareTo(Unsafe.AddByteOffset(ref second, num2));
1484 if (num7 != 0)
1485 {
1486 return num7;
1487 }
1488 }
1489 goto IL_0277;
1490 IL_021b:
1491 if (num3 > (nuint)sizeof(UIntPtr))
1492 {
1493 for (num3 -= (nuint)sizeof(UIntPtr); num3 > num2 && LoadNUInt(ref first, num2) == LoadNUInt(ref second, num2); num2 += (nuint)sizeof(UIntPtr))
1494 {
1495 }
1496 }
1497 goto IL_0273;
1498 IL_0111:
1499 uint value3 = ~num6;
1501 return Unsafe.AddByteOffset(ref first, num2).CompareTo(Unsafe.AddByteOffset(ref second, num2));
1502 }
static int TrailingZeroCount(int value)
static bool IsHardwareAccelerated
Definition Vector.cs:14
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 int MoveMask(Vector128< sbyte > value)
Definition Sse2.cs:772
static Vector128< sbyte > CompareEqual(Vector128< sbyte > left, Vector128< sbyte > right)
Definition Sse2.cs:232
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 nuint LoadNUInt(ref byte start)
static Vector256< byte > LoadVector256(ref byte start, nuint offset)

References System.Runtime.Intrinsics.X86.Sse2.CompareEqual(), System.Runtime.Intrinsics.X86.Avx2.CompareEqual(), System.Collections.Generic.Dictionary< TKey, TValue >.Count, System.Numerics.Vector< T >.IsHardwareAccelerated, System.Runtime.Intrinsics.X86.Avx2.IsSupported, System.Runtime.Intrinsics.X86.Sse2.IsSupported, System.SpanHelpers.LoadNUInt(), System.SpanHelpers.LoadVector(), System.SpanHelpers.LoadVector128(), System.SpanHelpers.LoadVector256(), System.Runtime.Intrinsics.X86.Sse2.MoveMask(), System.Runtime.Intrinsics.X86.Avx2.MoveMask(), System.Numerics.BitOperations.TrailingZeroCount(), and System.value.

Referenced by System.String.CompareOrdinal(), System.String.CompareOrdinalHelper(), System.MemoryExtensions.SequenceCompareTo< T >(), and System.MemoryExtensions.SequenceCompareTo< T >().