diff --git a/SabreTools.DatFiles/ItemDictionary.cs b/SabreTools.DatFiles/ItemDictionary.cs index c364d8fd..568125c8 100644 --- a/SabreTools.DatFiles/ItemDictionary.cs +++ b/SabreTools.DatFiles/ItemDictionary.cs @@ -845,26 +845,7 @@ namespace SabreTools.DatFiles foreach (var key in keys) #endif { - List? items = this[key]; - if (items == null) -#if NET40_OR_GREATER || NETCOREAPP - return; -#else - continue; -#endif - - // Filter all items in the current key - List newItems = []; - foreach (var item in items) - { - if (item.PassesFilter(filterRunner)) - newItems.Add(item); - } - - // Set the value in the key to the new set - Remove(key); - Add(key, newItems); - + ExecuteFilterOnBucket(filterRunner, key); #if NET40_OR_GREATER || NETCOREAPP }); #else @@ -872,6 +853,30 @@ namespace SabreTools.DatFiles #endif } + /// + /// Execute all filters in a filter runner on a single bucket + /// + /// Preconfigured filter runner to use + /// Name of the bucket to filter on + private void ExecuteFilterOnBucket(FilterRunner filterRunner, string bucketName) + { + List? items = GetItemsForBucket(bucketName); + if (items == null) + return; + + // Filter all items in the current key + List newItems = []; + foreach (var item in items) + { + if (item.PassesFilter(filterRunner)) + newItems.Add(item); + } + + // Set the value in the key to the new set + Remove(bucketName); + Add(bucketName, newItems); + } + #endregion #region Statistics