Skip to content

Commit 99e4a03

Browse files
committed
Remove redundant .AsSpan() / casts to {ReadOnly,}Span
1 parent f0b4c5e commit 99e4a03

File tree

15 files changed

+22
-24
lines changed

15 files changed

+22
-24
lines changed

src/BizHawk.Bizware.Graphics/D3D11/D3D11GLInterop.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ static D3D11GLInterop()
182182

183183
if (vendor == Vendor.Intel)
184184
{
185-
if (_blacklistedIntelDeviceIds.AsSpan().Contains(adapter.Description.DeviceId))
185+
if (_blacklistedIntelDeviceIds.Contains(adapter.Description.DeviceId))
186186
{
187187
return;
188188
}

src/BizHawk.Client.Common/RomLoader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ private void LoadOther(
557557
const string ERR_MSG_NOT_PSXEXE = "Got an .exe which is not in the PSX-EXE format!"
558558
+ "\nIf you're trying to load a PE (Windows program), you need to load the unextracted disc image. See https://tasvideos.org/BizHawk/DOSBox for details." // sadly won't be clickable
559559
+ "\n"; // extra blank line to separate from stacktrace below
560-
if (!rom.FileData.AsSpan().StartsWith("PS-X EXE"u8)) throw new /*NoAvailableCoreException*/InvalidOperationException(ERR_MSG_NOT_PSXEXE);
560+
if (!rom.FileData.StartsWith("PS-X EXE"u8)) throw new /*NoAvailableCoreException*/InvalidOperationException(ERR_MSG_NOT_PSXEXE);
561561
break;
562562
}
563563
var cip = new CoreInventoryParameters(this)

src/BizHawk.Client.Common/lua/LuaHelperLibs/EventsLuaLibrary.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,6 @@ private string ProcessScope(string scope)
351351

352352
private bool HasScope(string scope)
353353
=> string.IsNullOrWhiteSpace(scope)
354-
|| DebuggableCore.MemoryCallbacks.AvailableScopes.AsSpan().Contains(scope);
354+
|| DebuggableCore.MemoryCallbacks.AvailableScopes.Contains(scope);
355355
}
356356
}

src/BizHawk.Client.Common/movie/import/bkm/BkmControllerAdapter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public void SetControllersAsMnemonic(string mnemonic)
134134
SetFromMnemonic(mnemonic.AsSpan(3));
135135
break;
136136
case "Dual Gameboy Controller":
137-
SetFromMnemonic(mnemonic.AsSpan());
137+
SetFromMnemonic(mnemonic);
138138
break;
139139
case "WonderSwan Controller":
140140
SetFromMnemonic(mnemonic.AsSpan(1));

src/BizHawk.Common/BPSPatcher.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ internal void DoPatch(Span<byte> rom)
205205
private const string ERR_MSG_UNINIT = "uninitialised struct";
206206

207207
private static bool CheckCRC(ReadOnlySpan<byte> data, ReadOnlySpan<byte> reversedChecksum)
208-
=> ((ReadOnlySpan<byte>) CRC32Checksum.Compute(data)).ReversedSequenceEqual(reversedChecksum);
208+
=> CRC32Checksum.Compute(data).ReversedSequenceEqual(reversedChecksum);
209209

210210
public static bool IsBPSFile(ReadOnlySpan<byte> dataWithHeader, out BPSPayload patchStruct)
211211
{

src/BizHawk.Emulation.Common/N3DSHasher.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -382,19 +382,19 @@ private void HashNCCH(FileStream romFile, IncrementalHash md5Inc, byte[] header,
382382
if ((exeFsSectionSize & 0xF) != 0)
383383
{
384384
var ivCopy = new byte[iv.Length];
385-
iv.AsSpan().CopyTo(ivCopy);
385+
iv.CopyTo(ivCopy);
386386
exeFsSectionOffset &= ~0xFU;
387387

388388
// First decrypt these last bytes using the secondary key
389389
AesCtrTransform(aes, iv, exeFsBuffer.AsSpan((int)exeFsSectionOffset, (int)(0x10 - (exeFsSectionSize & 0xF))));
390390

391391
// Now re-encrypt these bytes using the primary key
392392
aes.Key = primaryKey;
393-
ivCopy.AsSpan().CopyTo(iv);
393+
ivCopy.CopyTo(iv);
394394
AesCtrTransform(aes, iv, exeFsBuffer.AsSpan((int)exeFsSectionOffset, (int)(0x10 - (exeFsSectionSize & 0xF))));
395395

396396
// All of the padding can now be decrypted using the primary key
397-
ivCopy.AsSpan().CopyTo(iv);
397+
ivCopy.CopyTo(iv);
398398
exeFsSectionSize += 0x10 - (exeFsSectionSize & 0xF);
399399
}
400400

src/BizHawk.Emulation.Cores/Computers/AmstradCPC/Media/Disk/FloppyDisk.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ public byte[] ActualData
641641
if (size > ActualDataByteLength)
642642
{
643643
var buf = new byte[SectorData.Length + size - ActualDataByteLength];
644-
SectorData.AsSpan().CopyTo(buf);
644+
SectorData.CopyTo(buf);
645645
// SectorData.AsSpan(start: 0, length: buf.Length - SectorData.Length)
646646
// .CopyTo(buf.AsSpan(start: SectorData.Length));
647647
buf.AsSpan(start: SectorData.Length).Fill(SectorData[SectorData.Length - 1]);

src/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.ISaveRam.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ private void LoadDelta(bool maybeDifferent)
6969
}
7070
else if (maybeDifferent)
7171
{
72-
original.AsSpan().CopyTo(current);
72+
original.CopyTo(current);
7373
}
7474
});
7575
}

src/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Am29F040B.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,8 @@ public void Reset()
144144
_endAddress = ImageMask;
145145
}
146146

147-
public Span<byte> Data =>
148-
_data.AsSpan();
147+
public Span<byte> Data
148+
=> _data;
149149

150150
public int Peek(int addr) =>
151151
_data[addr & ImageMask] & 0xFF;

src/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper0013.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public Mapper0013(IEnumerable<CartridgeChip> chips)
6262
var bank = new byte[BankSize];
6363

6464
bank.AsSpan().Fill(DummyData);
65-
chip.ConvertDataToBytes().CopyTo(bank.AsSpan());
65+
chip.ConvertDataToBytes().CopyTo(bank);
6666

6767
_banks[chip.Bank] = bank;
6868

0 commit comments

Comments
 (0)