mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Better equality code
This commit is contained in:
@@ -1106,6 +1106,26 @@ namespace SabreTools.Library.DatItems
|
||||
|
||||
#region Sorting and Merging
|
||||
|
||||
/// <summary>
|
||||
/// Determine if two hashes are equal for the purposes of merging
|
||||
/// </summary>
|
||||
/// <param name="firstHash">First hash to compare</param>
|
||||
/// <param name="secondHash">Second hash to compare</param>
|
||||
/// <returns>True if either is empty OR the hashes exactly match, false otherwise</returns>
|
||||
public static bool ConditionalHashEquals(byte[] firstHash, byte[] secondHash)
|
||||
{
|
||||
// If either hash is empty, we say they're equal for merging
|
||||
if (firstHash.IsNullOrEmpty() || secondHash.IsNullOrEmpty())
|
||||
return true;
|
||||
|
||||
// If they're different sizes, they can't match
|
||||
if (firstHash.Length != secondHash.Length)
|
||||
return false;
|
||||
|
||||
// Otherwise, they need to match exactly
|
||||
return Enumerable.SequenceEqual(firstHash, secondHash);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Merge an arbitrary set of ROMs based on the supplied information
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user