Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
do 8-char longs strings via SIMD path - it's smaller
  • Loading branch information
EgorBo committed Feb 10, 2022
commit a27a975f34228c6c1ed9a1e2f5bbc25d85814e6f
Original file line number Diff line number Diff line change
Expand Up @@ -689,9 +689,9 @@ public static bool Equals(string? a, string? b)
if (RuntimeHelpers.IsKnownConstant(b) && !RuntimeHelpers.IsKnownConstant(a) && b != null)
{
// Unroll using SWAR
if (b.Length <= 8)
if (b.Length <= 7)
{
return EqualsUnrolled_0_to_8(a, b);
return EqualsUnrolled_0_to_7(a, b);
}
// Unroll using two Vector128s
else if (b.Length <= 16 && Vector128.IsHardwareAccelerated)
Expand All @@ -704,7 +704,7 @@ public static bool Equals(string? a, string? b)
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
static bool EqualsUnrolled_0_to_8(string? a, string b)
static bool EqualsUnrolled_0_to_7(string? a, string b)
{
if (a != null)
{
Expand Down Expand Up @@ -746,7 +746,7 @@ static bool EqualsUnrolled_0_to_8(string? a, string b)
return a.Length == 4 && v1 == cns1;
}

// Handle Length [5..8] via two ulong (overlapped)
// Handle Length [5..7] via two ulong (overlapped)
return a.Length == b.Length && v1 == cns1 &&
ReadUInt64(a, b.Length - 4) == (((ulong)b[b.Length - 1] << 48) |
((ulong)b[b.Length - 2] << 32) |
Expand Down