diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/ValueType.cs b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/ValueType.cs index 7a1920d1fc1cb8..1b8333324d439b 100644 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/ValueType.cs +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/ValueType.cs @@ -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 {