diff --git a/SabreTools.DatFiles/DatFileTool.cs b/SabreTools.DatFiles/DatFileTool.cs index 08f078bd..e76d01a0 100644 --- a/SabreTools.DatFiles/DatFileTool.cs +++ b/SabreTools.DatFiles/DatFileTool.cs @@ -538,10 +538,7 @@ namespace SabreTools.DatFiles continue; var list = datFile.GetItemsForBucket(key); - if (list.Count == 0) - continue; - - if (datFile.Items.ContainsKey(key) && list.Count > 0) + if (list.Count > 0) Replacer.ReplaceFields(newDatItem.GetFieldValue(DatItem.MachineKey)!, list[index: 0].GetFieldValue(DatItem.MachineKey)!, machineFieldNames, onlySame); newDatItems.Add(newDatItem); diff --git a/SabreTools.DatFiles/ItemDictionary.cs b/SabreTools.DatFiles/ItemDictionary.cs index 1b18d23f..f4dc26b2 100644 --- a/SabreTools.DatFiles/ItemDictionary.cs +++ b/SabreTools.DatFiles/ItemDictionary.cs @@ -247,24 +247,6 @@ namespace SabreTools.DatFiles } } - /// - /// Get if the file dictionary contains the key - /// - /// Key in the dictionary to check - /// True if the key exists, false otherwise - public bool ContainsKey(string key) - { - // If the key is null, we return false since keys can't be null - if (key == null) - return false; - - // Explicit lock for some weird corner cases - lock (key) - { - return _items.ContainsKey(key); - } - } - /// /// Ensure the key exists in the items dictionary /// @@ -535,12 +517,11 @@ namespace SabreTools.DatFiles // We want to get the proper key for the DatItem string key = SortAndGetKey(datItem, sorted); - // If the key doesn't exist, return the empty list - if (!ContainsKey(key)) - return false; - // Try to find duplicates List roms = GetItemsForBucket(key); + if (roms.Count == 0) + return false; + return roms.FindIndex(r => datItem.Equals(r)) > -1; } diff --git a/SabreTools.DatTools/ExtraIni.cs b/SabreTools.DatTools/ExtraIni.cs index f2480bd4..9376b074 100644 --- a/SabreTools.DatTools/ExtraIni.cs +++ b/SabreTools.DatTools/ExtraIni.cs @@ -104,13 +104,9 @@ namespace SabreTools.DatTools // Apply the mappings foreach (string machine in machines) { - // If the key doesn't exist, continue - if (!datFile.Items.ContainsKey(machine)) - continue; - // Get the list of DatItems for the machine - var datItems = datFile.GetItemsForBucket(machine); - if (datItems == null) + List datItems = datFile.GetItemsForBucket(machine); + if (datItems.Count == 0) continue; // Try to get the map values, if possible