Skip to content

Commit edb7d7e

Browse files
authored
Use System.Numerics.IEqualityOperators.op_Equality in SpanHelper.T.cs where possible. (#74567)
* Use System.Numerics.IEqualityOperators.op_Equality in SpanHelper.T.cs. Workaround crash hit by #74179 making sure we avoid hitting codepath emitting this null pointer checks. The full fix includes codegen fixes as well, but will be performed in separate PR. There are still locations in SpanHelper.T.cs that uses Equal virtual call on value types that could be managed pointers to value types, but that code has remained the same for the last 4 years to 15 months and have not hit this issue in the past. * Re-enable globalization tests disabled in #74433.
1 parent 48a3dbe commit edb7d7e

File tree

3 files changed

+2
-5
lines changed

3 files changed

+2
-5
lines changed

src/libraries/System.Globalization/tests/CompareInfo/CompareInfoTests.IndexOf.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,6 @@ public static IEnumerable<object[]> IndexOf_U_WithDiaeresis_TestData()
183183
[MemberData(nameof(IndexOf_TestData))]
184184
[MemberData(nameof(IndexOf_Aesc_Ligature_TestData))]
185185
[MemberData(nameof(IndexOf_U_WithDiaeresis_TestData))]
186-
[ActiveIssue("https://github.com/dotnet/runtime/issues/74179", TestRuntimes.Mono)]
187186
public void IndexOf_String(CompareInfo compareInfo, string source, string value, int startIndex, int count, CompareOptions options, int expected, int expectedMatchLength)
188187
{
189188
if (value.Length == 1)

src/libraries/System.Globalization/tests/Invariant/InvariantMode.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,6 @@ private static StringComparison GetStringComparison(CompareOptions options)
864864

865865
[ConditionalTheory(nameof(PredefinedCulturesOnlyIsDisabled))]
866866
[MemberData(nameof(IndexOf_TestData))]
867-
[ActiveIssue("https://github.com/dotnet/runtime/issues/74179", TestRuntimes.Mono)]
868867
public void TestIndexOf(string source, string value, int startIndex, int count, CompareOptions options, int result)
869868
{
870869
foreach (string cul in s_cultureNames)
@@ -912,7 +911,6 @@ static void TestCore(CompareInfo compareInfo, string source, string value, int s
912911

913912
[ConditionalTheory(nameof(PredefinedCulturesOnlyIsDisabled))]
914913
[MemberData(nameof(LastIndexOf_TestData))]
915-
[ActiveIssue("https://github.com/dotnet/runtime/issues/74179", TestRuntimes.Mono)]
916914
public void TestLastIndexOf(string source, string value, int startIndex, int count, CompareOptions options, int result)
917915
{
918916
foreach (string cul in s_cultureNames)

src/libraries/System.Private.CoreLib/src/System/SpanHelpers.T.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1498,7 +1498,7 @@ private static int IndexOfValueType<TValue, TNegator>(ref TValue searchSpace, TV
14981498
{
14991499
length -= 1;
15001500

1501-
if (TNegator.NegateIfNeeded(Unsafe.Add(ref searchSpace, offset).Equals(value))) return (int)offset;
1501+
if (TNegator.NegateIfNeeded(Unsafe.Add(ref searchSpace, offset) == value)) return (int)offset;
15021502

15031503
offset += 1;
15041504
}
@@ -2145,7 +2145,7 @@ private static int LastIndexOfValueType<TValue, TNegator>(ref TValue searchSpace
21452145
{
21462146
length -= 1;
21472147

2148-
if (TNegator.NegateIfNeeded(Unsafe.Add(ref searchSpace, offset).Equals(value))) return (int)offset;
2148+
if (TNegator.NegateIfNeeded(Unsafe.Add(ref searchSpace, offset) == value)) return (int)offset;
21492149

21502150
offset -= 1;
21512151
}

0 commit comments

Comments
 (0)