Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove mono specific SpanHelpers #79215

Merged
merged 13 commits into from
Dec 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -2526,7 +2526,4 @@
<Compile Include="$(MSBuildThisFileDirectory)System\Numerics\IUnaryPlusOperators.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Numerics\IUnsignedNumber.cs" />
</ItemGroup>
<ItemGroup Condition="'$(FeatureMono)' == 'true'">
<Compile Include="$(MSBuildThisFileDirectory)System\SpanHelpers.Mono.cs" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -1750,7 +1750,6 @@ public static unsafe int IndexOfAny<T>(this ReadOnlySpan<T> span, ReadOnlySpan<T
Unsafe.Add(ref valueRef, 2),
span.Length);

#if !MONO // We don't have a mono overload for 4 values
case 4:
return SpanHelpers.IndexOfAnyValueType(
ref spanRef,
Expand All @@ -1759,7 +1758,7 @@ public static unsafe int IndexOfAny<T>(this ReadOnlySpan<T> span, ReadOnlySpan<T
Unsafe.Add(ref valueRef, 2),
Unsafe.Add(ref valueRef, 3),
span.Length);
#endif

case 5:
return SpanHelpers.IndexOfAnyValueType(
ref spanRef,
Expand Down Expand Up @@ -2025,7 +2024,6 @@ public static unsafe int LastIndexOfAny<T>(this ReadOnlySpan<T> span, ReadOnlySp
Unsafe.Add(ref valueRef, 2),
span.Length);

#if !MONO // We don't have a mono overload for 4 values
case 4:
return SpanHelpers.LastIndexOfAnyValueType(
ref spanRef,
Expand All @@ -2034,7 +2032,6 @@ public static unsafe int LastIndexOfAny<T>(this ReadOnlySpan<T> span, ReadOnlySp
Unsafe.Add(ref valueRef, 2),
Unsafe.Add(ref valueRef, 3),
span.Length);
#endif

case 5:
return SpanHelpers.LastIndexOfAnyValueType(
Expand Down Expand Up @@ -2075,7 +2072,6 @@ public static unsafe int LastIndexOfAny<T>(this ReadOnlySpan<T> span, ReadOnlySp
Unsafe.Add(ref valueRef, 2),
span.Length);

#if !MONO // We don't have a mono overload for 4 values
BrzVlad marked this conversation as resolved.
Show resolved Hide resolved
case 4:
return SpanHelpers.LastIndexOfAnyValueType(
ref spanRef,
Expand All @@ -2084,7 +2080,6 @@ public static unsafe int LastIndexOfAny<T>(this ReadOnlySpan<T> span, ReadOnlySp
Unsafe.Add(ref valueRef, 2),
Unsafe.Add(ref valueRef, 3),
span.Length);
#endif

case 5:
return SpanHelpers.LastIndexOfAnyValueType(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -986,13 +986,21 @@ public static nuint CommonPrefixLength(ref byte first, ref byte second, nuint le

for (; (nint)i <= (nint)length - 4; i += 4)
{
if (Unsafe.Add(ref first, i + 0) != Unsafe.Add(ref second, i + 0)) return i + 0;
if (Unsafe.Add(ref first, i + 1) != Unsafe.Add(ref second, i + 1)) return i + 1;
if (Unsafe.Add(ref first, i + 2) != Unsafe.Add(ref second, i + 2)) return i + 2;
if (Unsafe.Add(ref first, i + 3) != Unsafe.Add(ref second, i + 3)) return i + 3;
if (Unsafe.Add(ref first, i + 0) != Unsafe.Add(ref second, i + 0)) goto Found0;
if (Unsafe.Add(ref first, i + 1) != Unsafe.Add(ref second, i + 1)) goto Found1;
if (Unsafe.Add(ref first, i + 2) != Unsafe.Add(ref second, i + 2)) goto Found2;
if (Unsafe.Add(ref first, i + 3) != Unsafe.Add(ref second, i + 3)) goto Found3;
}

return length;
Found0:
return i;
Found1:
return i + 1;
Found2:
return i + 2;
Found3:
return i + 3;
}

Debug.Assert(length >= (uint)Vector128<byte>.Count);
Expand Down
Loading