Skip to content

Commit

Permalink
Speed up ValueType.Equals (#69768)
Browse files Browse the repository at this point in the history
Inspired by #69723 

`SpanHelpers` didn't exist when this part of NativeAOT was written (dotnet/corert#5436 (comment)).
  • Loading branch information
MichalStrehovsky authored May 25, 2022
1 parent 0df1214 commit 0dba0ee
Showing 1 changed file with 1 addition and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,7 @@ public override bool Equals([NotNullWhen(true)] object? obj)

// Compare the memory
int valueTypeSize = (int)this.GetEETypePtr().ValueTypeSize;
for (int i = 0; i < valueTypeSize; i++)
{
if (Unsafe.Add(ref thisRawData, i) != Unsafe.Add(ref thatRawData, i))
return false;
}
return SpanHelpers.SequenceEqual(ref thisRawData, ref thatRawData, valueTypeSize);
}
else
{
Expand Down

0 comments on commit 0dba0ee

Please # to comment.