未验证 提交 edb7d7e3 编写于 作者: J Johan Lorensson 提交者: GitHub

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 https://github.com/dotnet/runtime/issues/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.
上级 48a3dbe5
......@@ -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)
......
......@@ -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)
......@@ -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)
......
......@@ -1498,7 +1498,7 @@ internal static int IndexOfChar(ref char searchSpace, char value, int length)
{
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;
}
......@@ -2145,7 +2145,7 @@ internal static int IndexOfAnyValueType<T>(ref T searchSpace, T value0, T value1
{
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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册