Skip to content

Commit 78b189f

Browse files
committed
Use Span<T>.Contains for arrays
1 parent d17df09 commit 78b189f

File tree

5 files changed

+5
-18
lines changed

5 files changed

+5
-18
lines changed

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
using Vortice.Direct3D11;
77
using Vortice.DXGI;
88

9-
using BizHawk.Common.CollectionExtensions;
10-
119
using static SDL2.SDL;
1210

1311
namespace BizHawk.Bizware.Graphics
@@ -184,7 +182,7 @@ static D3D11GLInterop()
184182

185183
if (vendor == Vendor.Intel)
186184
{
187-
if (_blacklistedIntelDeviceIds.Contains(adapter.Description.DeviceId))
185+
if (_blacklistedIntelDeviceIds.AsSpan().Contains(adapter.Description.DeviceId))
188186
{
189187
return;
190188
}

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using System.Linq;
21
using System.ComponentModel;
32

43
using NLua;
@@ -351,8 +350,7 @@ private string ProcessScope(string scope)
351350
}
352351

353352
private bool HasScope(string scope)
354-
{
355-
return string.IsNullOrWhiteSpace(scope) || DebuggableCore.MemoryCallbacks.AvailableScopes.Contains(scope);
356-
}
353+
=> string.IsNullOrWhiteSpace(scope)
354+
|| DebuggableCore.MemoryCallbacks.AvailableScopes.AsSpan().Contains(scope);
357355
}
358356
}

src/BizHawk.Common/Extensions/CollectionExtensions.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -246,13 +246,6 @@ public static IEnumerable<T[]> Chunk<T>(this IEnumerable<T> source, int size)
246246
yield return (Start: numbers[blockStart], Count: i - blockStart); // `count` arg will be 0 if the whole list is contiguous
247247
}
248248

249-
/// <remarks>
250-
/// Contains method for arrays which does not need Linq, but rather uses Array.IndexOf
251-
/// similar to <see cref="ICollection{T}.Contains">ICollection's Contains</see>
252-
/// </remarks>
253-
public static bool Contains<T>(this T[] array, T value)
254-
=> Array.IndexOf(array, value) >= 0;
255-
256249
/// <returns>
257250
/// portion of <paramref name="dest"/> that was written to,
258251
/// unless either span is empty, in which case the other reference is returned<br/>

src/BizHawk.Emulation.Cores/Consoles/Nintendo/NDS/NDSFirmware.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using System.Linq;
21
using System.Runtime.InteropServices;
32

43
using BizHawk.Common;
@@ -66,7 +65,7 @@ private static unsafe void CheckDecryptedCodeChecksum(
6665
try
6766
{
6867
var hash = SHA1Checksum.ComputeDigestHex(Util.UnsafeSpanFromPointer(decryptedFw, decrypedFwLen));
69-
if (!_goodHashes.Contains(hash))
68+
if (!_goodHashes.AsSpan().Contains(hash))
7069
{
7170
warningCallback($"Potentially bad firmware dump! Decrypted hash {hash} does not match known good dumps.");
7271
}

src/BizHawk.Emulation.Cores/Waterbox/NymaCore.Controller.ButtonNameOverrides.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
using System.Collections.Generic;
22
using System.Globalization;
3-
using System.Linq;
43
using System.Text.RegularExpressions;
54

65
namespace BizHawk.Emulation.Cores.Waterbox
76
{
87
public abstract partial class NymaCore
98
{
109
private static bool IsRomanNumeral(string str)
11-
=> new[] {"I", "II", "III", "IV", "V", "VI"}.Contains(str);
10+
=> str is "I" or "II" or "III" or "IV" or "V" or "VI";
1211

1312
private static readonly Dictionary<string, string> ButtonNameOverrides = new Dictionary<string, string>
1413
{

0 commit comments

Comments
 (0)