Skip to content

Commit

Permalink
Remove unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
shargon committed Feb 6, 2025
1 parent b4e5418 commit f6b0c11
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 32 deletions.
16 changes: 0 additions & 16 deletions src/Neo.Extensions/ByteArrayComparer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
// modifications are permitted.

using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.CompilerServices;

Expand Down Expand Up @@ -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);
}

/// <inheritdoc />
[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[]);
}
}
}
17 changes: 1 addition & 16 deletions src/Neo.Extensions/ByteArrayEqualityComparer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<byte[]>, IEqualityComparer
public class ByteArrayEqualityComparer : IEqualityComparer<byte[]>
{
public static readonly ByteArrayEqualityComparer Instance = new();

Expand All @@ -29,20 +28,6 @@ public bool Equals(byte[]? x, byte[]? y)
return x.AsSpan().SequenceEqual(y.AsSpan());
}

/// <inheritdoc />
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`
}

/// <inheritdoc />
public int GetHashCode([DisallowNull] byte[] obj) =>
obj.XxHash3_32();
Expand Down

0 comments on commit f6b0c11

Please sign in to comment.