Use index-based removal of items

This commit is contained in:
Matt Nadareski
2025-05-02 09:37:09 -04:00
parent b51d6ce2c5
commit 0b34163af3

View File

@@ -303,13 +303,15 @@ namespace SabreTools.DatFiles
#endif
// If the value doesn't exist in the key, return
if (!list.Exists(i => i.Equals(value)))
int removeIndex = list.FindIndex(i => i.Equals(value));
if (removeIndex < 0)
return false;
// Remove the statistics first
DatStatistics.RemoveItemStatistics(value);
return list.Remove(value);
list.RemoveAt(removeIndex);
return true;
}
}