diff --git a/src/BizHawk.Emulation.DiscSystem/DiscHasher.cs b/src/BizHawk.Emulation.DiscSystem/DiscHasher.cs
index 4f2869aec7..8689e87dfd 100644
--- a/src/BizHawk.Emulation.DiscSystem/DiscHasher.cs
+++ b/src/BizHawk.Emulation.DiscSystem/DiscHasher.cs
@@ -36,7 +36,7 @@ namespace BizHawk.Emulation.DiscSystem
//hash the TOC
static void AddAsBytesTo(SpecialCRC32 crc32, int i)
- => crc32.Add(BitConverter.GetBytes(i), 0, 4);
+ => crc32.Add(BitConverter.GetBytes(i));
AddAsBytesTo(crc, (int)disc.TOC.Session1Format);
AddAsBytesTo(crc, disc.TOC.FirstRecordedTrackNumber);
AddAsBytesTo(crc, disc.TOC.LastRecordedTrackNumber);
@@ -52,7 +52,7 @@ namespace BizHawk.Emulation.DiscSystem
for (int i = 0; i < 26; i++)
{
dsr.ReadLBA_2352(i, buffer2352, 0);
- crc.Add(buffer2352, 0, 2352);
+ crc.Add(buffer2352);
}
return crc.Result;
@@ -77,7 +77,7 @@ namespace BizHawk.Emulation.DiscSystem
for (int i = 0; i < disc.Session1.LeadoutLBA; i++)
{
dsr.ReadLBA_2352(i, buffer2352, 0);
- crc.Add(buffer2352, 0, 2352);
+ crc.Add(buffer2352);
}
return crc.Result;
@@ -131,22 +131,9 @@ namespace BizHawk.Emulation.DiscSystem
private uint current = 0xFFFFFFFF;
- ///
- /// is negative, or
- /// end index ( + ) is beyond the end of
- ///
- public unsafe void Add(byte[] data, int offset, int size)
+ public void Add(ReadOnlySpan data)
{
- if (offset + size > data.Length)
- throw new ArgumentOutOfRangeException();
- if (offset < 0)
- throw new ArgumentOutOfRangeException();
- fixed (byte* pData = data)
- for (int i = 0; i < size; i++)
- {
- byte b = pData[offset + i];
- current = CRC32Table[(current ^ b) & 0xFF] ^ (current >> 8);
- }
+ foreach (var b in data) current = CRC32Table[(current ^ b) & 0xFF] ^ (current >> 8);
}
///
diff --git a/src/BizHawk.Tests/Common/checksums/CRC32Tests.cs b/src/BizHawk.Tests/Common/checksums/CRC32Tests.cs
index 70b29cb12b..b1f7502d7c 100644
--- a/src/BizHawk.Tests/Common/checksums/CRC32Tests.cs
+++ b/src/BizHawk.Tests/Common/checksums/CRC32Tests.cs
@@ -35,12 +35,12 @@ namespace BizHawk.Tests.Common.checksums
data = InitialiseArray();
DiscHasher.SpecialCRC32 crc32 = new();
- crc32.Add(data, 0, data.Length);
+ crc32.Add(data);
Assert.AreEqual(EXPECTED, crc32.Result);
var dataExtra = InitialiseArrayExtra();
DiscHasher.SpecialCRC32 crc32Extra = new();
- crc32Extra.Add(dataExtra, 0, dataExtra.Length);
+ crc32Extra.Add(dataExtra);
Assert.AreEqual(EXPECTED_EXTRA, crc32Extra.Result);
crc32.Incorporate(crc32Extra.Result, dataExtra.Length);
Assert.AreEqual(EXPECTED_COMBINED, crc32.Result);