Split IDDB filtering into a helper method

This commit is contained in:
Matt Nadareski
2024-03-19 14:10:51 -04:00
parent b03628ca9e
commit 6cb8f60917

View File

@@ -858,13 +858,24 @@ namespace SabreTools.DatFiles
foreach (var key in keys) foreach (var key in keys)
#endif #endif
{ {
(long, DatItem)[]? items = GetDatItemsForBucket(key); ExecuteFilterOnBucket(filterRunner, key);
if (items == null)
#if NET40_OR_GREATER || NETCOREAPP #if NET40_OR_GREATER || NETCOREAPP
return; });
#else #else
continue; }
#endif #endif
}
/// <summary>
/// Execute all filters in a filter runner on a single bucket
/// </summary>
/// <param name="filterRunner">Preconfigured filter runner to use</param>
/// <param name="bucketName">Name of the bucket to filter on</param>
private void ExecuteFilterOnBucket(FilterRunner filterRunner, string bucketName)
{
(long, DatItem)[]? items = GetDatItemsForBucket(bucketName);
if (items == null)
return;
// Filter all items in the current key // Filter all items in the current key
var newItems = new ConcurrentList<(long, DatItem)>(); var newItems = new ConcurrentList<(long, DatItem)>();
@@ -875,13 +886,7 @@ namespace SabreTools.DatFiles
} }
// Set the value in the key to the new set // Set the value in the key to the new set
_buckets[key] = newItems.Select(i => i.Item1).ToConcurrentList(); _buckets[bucketName] = newItems.Select(i => i.Item1).ToConcurrentList();
#if NET40_OR_GREATER || NETCOREAPP
});
#else
}
#endif
} }
#endregion #endregion