Skip to content

Commit

Permalink
[release/7.0] Use System.Numerics.IEqualityOperators.op_Equality in S…
Browse files Browse the repository at this point in the history
…panHelper.T.cs where possible. (#74738)

* 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.

Co-authored-by: lateralusX <lateralusx.github@gmail.com>
  • Loading branch information
github-actions[bot] and lateralusX committed Aug 29, 2022
1 parent fe99c44 commit 099304f
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ public static IEnumerable<object[]> IndexOf_U_WithDiaeresis_TestData()
[MemberData(nameof(IndexOf_TestData))]
[MemberData(nameof(IndexOf_Aesc_Ligature_TestData))]
[MemberData(nameof(IndexOf_U_WithDiaeresis_TestData))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/74179", TestRuntimes.Mono)]
public void IndexOf_String(CompareInfo compareInfo, string source, string value, int startIndex, int count, CompareOptions options, int expected, int expectedMatchLength)
{
if (value.Length == 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,6 @@ private static StringComparison GetStringComparison(CompareOptions options)

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

[ConditionalTheory(nameof(PredefinedCulturesOnlyIsDisabled))]
[MemberData(nameof(LastIndexOf_TestData))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/74179", TestRuntimes.Mono)]
public void TestLastIndexOf(string source, string value, int startIndex, int count, CompareOptions options, int result)
{
foreach (string cul in s_cultureNames)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1498,7 +1498,7 @@ private static int IndexOfValueType<TValue, TNegator>(ref TValue searchSpace, TV
{
length -= 1;

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

offset += 1;
}
Expand Down Expand Up @@ -2145,7 +2145,7 @@ private static int LastIndexOfValueType<TValue, TNegator>(ref TValue searchSpace
{
length -= 1;

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

offset -= 1;
}
Expand Down

0 comments on commit 099304f

Please sign in to comment.