From 4800fef65e4811f84119194691152940582ad657 Mon Sep 17 00:00:00 2001 From: YoshiRulz Date: Mon, 8 Feb 2021 10:55:27 +1000 Subject: [PATCH] Cleanup dumb LINQ in FirmwareManager --- src/BizHawk.Client.Common/FirmwareManager.cs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/BizHawk.Client.Common/FirmwareManager.cs b/src/BizHawk.Client.Common/FirmwareManager.cs index 08b825144c..8991f59021 100644 --- a/src/BizHawk.Client.Common/FirmwareManager.cs +++ b/src/BizHawk.Client.Common/FirmwareManager.cs @@ -115,14 +115,13 @@ namespace BizHawk.Client.Common return false; // weed out filesizes first to reduce the unnecessary overhead of a hashing operation - if (FirmwareDatabase.FirmwareFiles.FirstOrDefault(a => a.Size == fi.Length) == null) - return false; + if (FirmwareDatabase.FirmwareFiles.All(a => a.Size != fi.Length)) return false; // check the hash using var reader = new RealFirmwareReader(); reader.Read(fi); - if (FirmwareDatabase.FirmwareFiles.FirstOrDefault(a => a.Hash == reader.Dict.FirstOrDefault().Value.Hash) != null) - return true; + var hash = reader.Dict.Values.First().Hash; + if (FirmwareDatabase.FirmwareFiles.Any(a => a.Hash == hash)) return true; } catch { } @@ -245,10 +244,7 @@ namespace BizHawk.Client.Common ri.KnownFirmwareFile = ff; // if the known firmware file is for a different firmware, flag it so we can show a warning - var option = FirmwareDatabase.FirmwareOptions - .FirstOrDefault(fo => fo.Hash == rff.Hash && fo.ConfigKey != fr.ConfigKey); - - if (option != null) + if (FirmwareDatabase.FirmwareOptions.Any(fo => fo.Hash == rff.Hash && fo.ConfigKey != fr.ConfigKey)) { ri.KnownMismatching = true; }