diff --git a/src/Neo.Extensions/ByteArrayComparer.cs b/src/Neo.Extensions/ByteArrayComparer.cs index 553f00f51a..b890b0b5bf 100644 --- a/src/Neo.Extensions/ByteArrayComparer.cs +++ b/src/Neo.Extensions/ByteArrayComparer.cs @@ -10,7 +10,6 @@ // modifications are permitted. using System; -using System.Collections; using System.Collections.Generic; using System.Runtime.CompilerServices; @@ -48,20 +47,5 @@ public int Compare(byte[]? x, byte[]? y) // value would be "int.MaxValue + 1" return unchecked(x.AsSpan().SequenceCompareTo(y.AsSpan()) * _direction); } - - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public int Compare(object? x, object? y) - { - if (ReferenceEquals(x, y)) return 0; - - if (x is not null and not byte[]) - throw new ArgumentException($"Unable to cast '{x.GetType().FullName}' to '{typeof(byte[]).FullName}'."); - - if (y is not null and not byte[]) - throw new ArgumentException($"Unable to cast '{y.GetType().FullName}' to '{typeof(byte[]).FullName}'."); - - return Compare(x as byte[], y as byte[]); - } } } diff --git a/src/Neo.Extensions/ByteArrayEqualityComparer.cs b/src/Neo.Extensions/ByteArrayEqualityComparer.cs index a8f63cacd8..091185bd02 100644 --- a/src/Neo.Extensions/ByteArrayEqualityComparer.cs +++ b/src/Neo.Extensions/ByteArrayEqualityComparer.cs @@ -10,13 +10,12 @@ // modifications are permitted. using System; -using System.Collections; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; namespace Neo.Extensions { - public class ByteArrayEqualityComparer : IEqualityComparer, IEqualityComparer + public class ByteArrayEqualityComparer : IEqualityComparer { public static readonly ByteArrayEqualityComparer Instance = new(); @@ -29,20 +28,6 @@ public bool Equals(byte[]? x, byte[]? y) return x.AsSpan().SequenceEqual(y.AsSpan()); } - /// - public new bool Equals(object? x, object? y) - { - if (ReferenceEquals(x, y)) return true; // Check is `null` or same object instance - - if (x is not null and not byte[]) - throw new ArgumentException($"Unable to cast '{x.GetType().FullName}' to '{typeof(byte[]).FullName}'."); - - if (y is not null and not byte[]) - throw new ArgumentException($"Unable to cast '{y.GetType().FullName}' to '{typeof(byte[]).FullName}'."); - - return Equals(x as byte[], y as byte[]); // if x or y isn't byte array they will be `null` - } - /// public int GetHashCode([DisallowNull] byte[] obj) => obj.XxHash3_32();