mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Remove ContainsKey as it was really unneeded
This commit is contained in:
@@ -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<Machine>(DatItem.MachineKey)!, list[index: 0].GetFieldValue<Machine>(DatItem.MachineKey)!, machineFieldNames, onlySame);
|
||||
|
||||
newDatItems.Add(newDatItem);
|
||||
|
||||
@@ -247,24 +247,6 @@ namespace SabreTools.DatFiles
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get if the file dictionary contains the key
|
||||
/// </summary>
|
||||
/// <param name="key">Key in the dictionary to check</param>
|
||||
/// <returns>True if the key exists, false otherwise</returns>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ensure the key exists in the items dictionary
|
||||
/// </summary>
|
||||
@@ -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<DatItem> roms = GetItemsForBucket(key);
|
||||
if (roms.Count == 0)
|
||||
return false;
|
||||
|
||||
return roms.FindIndex(r => datItem.Equals(r)) > -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -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<DatItem> datItems = datFile.GetItemsForBucket(machine);
|
||||
if (datItems.Count == 0)
|
||||
continue;
|
||||
|
||||
// Try to get the map values, if possible
|
||||
|
||||
Reference in New Issue
Block a user