From 4ec2b80ecbb1cf00cd11b4e935f8441e15c8a258 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Mon, 14 Apr 2025 14:06:00 -0400 Subject: [PATCH] Fun with HashSets --- SabreTools.Core/DictionaryBaseExtensions.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/SabreTools.Core/DictionaryBaseExtensions.cs b/SabreTools.Core/DictionaryBaseExtensions.cs index 319c52bc..7e1e8cef 100644 --- a/SabreTools.Core/DictionaryBaseExtensions.cs +++ b/SabreTools.Core/DictionaryBaseExtensions.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Linq; using SabreTools.Hashing; using SabreTools.Models.Metadata; @@ -148,9 +149,9 @@ namespace SabreTools.Core return false; // If any keys are missing on either side, they can't match - if (self.Keys.Except(other.Keys).Any()) - return false; - if (other.Keys.Except(self.Keys).Any()) + var selfKeys = new HashSet(self.Keys); + var otherKeys = new HashSet(other.Keys); + if (!selfKeys.SetEquals(otherKeys)) return false; // Check all pairs to see if they're equal @@ -687,7 +688,8 @@ namespace SabreTools.Core case (Rom romSelf, Rom romOther): romSelf.FillMissingHashes(romOther); break; - }; + } + ; } ///