Skip to content

Commit

Permalink
remove ByteArrayCompare
Browse files Browse the repository at this point in the history
  • Loading branch information
Luchuan committed Jul 16, 2020
1 parent 82cc20b commit ce886ed
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions src/LevelDBStore/IO/Data/LevelDB/Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,6 @@ namespace Neo.IO.Data.LevelDB
{
public static class Helper
{
private static int ByteArrayCompare(byte[] x, byte[] y)
{
int length = Math.Min(x.Length, y.Length);
for (int i = 0; i < length; i++)
{
int r = x[i].CompareTo(y[i]);
if (r != 0) return r;
}
return x.Length.CompareTo(y.Length);
}

public static IEnumerable<T> Seek<T>(this DB db, ReadOptions options, byte table, byte[] prefix, SeekDirection direction, Func<byte[], byte[], T> resultSelector)
{
using Iterator it = db.NewIterator(options);
Expand All @@ -38,7 +27,7 @@ public static IEnumerable<T> Seek<T>(this DB db, ReadOptions options, byte table
it.Seek(target);
if (!it.Valid())
it.SeekToLast();
else if (ByteArrayCompare(it.Key(), target) > 0)
else if (it.Key().AsSpan().SequenceCompareTo(target) > 0)
it.Prev();

for (; it.Valid(); it.Prev())
Expand Down

0 comments on commit ce886ed

Please sign in to comment.