Skip to content

Commit 267fac9

Browse files
committed
Added Span code for future versions.
1 parent 9d191fc commit 267fac9

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

ReClass.NET/MemoryScanner/BytePattern.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,27 @@ public static BytePattern From(IEnumerable<Tuple<byte, bool>> data)
201201
return pattern;
202202
}
203203

204+
// TODO: Use System.Span after it is available
205+
/*/// <summary>
206+
/// Tests if the provided byte array matches the byte pattern at the provided index.
207+
/// </summary>
208+
/// <param name="data">The byte array to be compared.</param>
209+
/// <returns>True if the pattern matches, false if they are not.</returns>
210+
public bool Equals(Span<byte> data)
211+
{
212+
Contract.Requires(data != null);
213+
214+
for (var j = 0; j < pattern.Count; ++j)
215+
{
216+
if (!pattern[j].Equals(data[j]))
217+
{
218+
return false;
219+
}
220+
}
221+
222+
return true;
223+
}*/
224+
204225
/// <summary>
205226
/// Tests if the provided byte array matches the byte pattern at the provided index.
206227
/// </summary>

ReClass.NET/MemoryScanner/Comparer/ArrayOfBytesMemoryComparer.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ public unsafe bool Compare(byte* data, out ScanResult result)
4444
}
4545
}
4646
}
47+
// TODO: Use System.Span after it is available
48+
//else if (!bytePattern.Equals(new Span<byte>(data, ValueSize)))
4749
else if (!bytePattern.Equals(data))
4850
{
4951
return false;

ReClass.NET/MemoryScanner/PatternScanner.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ private static int FindPattern(BytePattern pattern, byte[] data)
7979
var limit = data.Length - pattern.Length;
8080
for (var i = 0; i < limit; ++i)
8181
{
82+
// TODO: Use System.Span after it is available
83+
// if (pattern.Equals(new Span<byte>(data, i, pattern.Length)))
8284
if (pattern.Equals(data, i))
8385
{
8486
return i;

0 commit comments

Comments
 (0)