Add SequenceEqual extension to prevent linq usage
this speeds up the state history integrity check by about an order of magnitude
This commit is contained in:
parent
1dbd7356eb
commit
7ab2ca6b89
src
|
@ -8,6 +8,8 @@ using System.Drawing.Imaging;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
using BizHawk.Common.CollectionExtensions;
|
||||||
|
|
||||||
using SDGraphics = System.Drawing.Graphics;
|
using SDGraphics = System.Drawing.Graphics;
|
||||||
|
|
||||||
namespace BizHawk.Bizware.Graphics
|
namespace BizHawk.Bizware.Graphics
|
||||||
|
@ -34,10 +36,6 @@ namespace BizHawk.Bizware.Graphics
|
||||||
private GCHandle CurrLockHandle;
|
private GCHandle CurrLockHandle;
|
||||||
private BitmapData CurrLock;
|
private BitmapData CurrLock;
|
||||||
|
|
||||||
/// <summary>same as <see cref="Pixels"/> (<see cref="PixelFormat.Format32bppArgb">A8R8G8B8</see>)</summary>
|
|
||||||
public Span<int> AsSpan()
|
|
||||||
=> Pixels;
|
|
||||||
|
|
||||||
/// <exception cref="InvalidOperationException">already locked</exception>
|
/// <exception cref="InvalidOperationException">already locked</exception>
|
||||||
/// <remarks>TODO add read/write semantic, for wraps</remarks>
|
/// <remarks>TODO add read/write semantic, for wraps</remarks>
|
||||||
public BitmapData LockBits()
|
public BitmapData LockBits()
|
||||||
|
@ -545,7 +543,7 @@ namespace BizHawk.Bizware.Graphics
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool SequenceEqual(BitmapBuffer other)
|
public bool SequenceEqual(BitmapBuffer other)
|
||||||
=> Width == other.Width && Height == other.Height && AsSpan().SequenceEqual(other.AsSpan());
|
=> Width == other.Width && Height == other.Height && Pixels.SequenceEqual(other.Pixels);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Dumps this BitmapBuffer to a new System.Drawing.Bitmap
|
/// Dumps this BitmapBuffer to a new System.Drawing.Bitmap
|
||||||
|
@ -607,4 +605,4 @@ namespace BizHawk.Bizware.Graphics
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -321,5 +321,7 @@ namespace BizHawk.Common.CollectionExtensions
|
||||||
for (int i = 0, e = span.Length - 1; i < e; i++) if (span[i + 1].CompareTo(span[i]) > 0) return false;
|
for (int i = 0, e = span.Length - 1; i < e; i++) if (span[i + 1].CompareTo(span[i]) > 0) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool SequenceEqual<T>(this T[] a, ReadOnlySpan<T> b) where T : IEquatable<T> => a.AsSpan().SequenceEqual(b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue