Fun with HashSets

This commit is contained in:
Matt Nadareski
2025-04-14 14:06:00 -04:00
parent 7726ef4552
commit 4ec2b80ecb

View File

@@ -1,4 +1,5 @@
using System; using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using SabreTools.Hashing; using SabreTools.Hashing;
using SabreTools.Models.Metadata; using SabreTools.Models.Metadata;
@@ -148,9 +149,9 @@ namespace SabreTools.Core
return false; return false;
// If any keys are missing on either side, they can't match // If any keys are missing on either side, they can't match
if (self.Keys.Except(other.Keys).Any()) var selfKeys = new HashSet<string>(self.Keys);
return false; var otherKeys = new HashSet<string>(other.Keys);
if (other.Keys.Except(self.Keys).Any()) if (!selfKeys.SetEquals(otherKeys))
return false; return false;
// Check all pairs to see if they're equal // Check all pairs to see if they're equal
@@ -687,7 +688,8 @@ namespace SabreTools.Core
case (Rom romSelf, Rom romOther): case (Rom romSelf, Rom romOther):
romSelf.FillMissingHashes(romOther); romSelf.FillMissingHashes(romOther);
break; break;
}; }
;
} }
/// <summary> /// <summary>