mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Fully move ExecuteFilters, add TODO
This commit is contained in:
@@ -10,7 +10,6 @@ using System.Threading.Tasks;
|
||||
#endif
|
||||
using System.Xml.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
using SabreTools.Core.Filter;
|
||||
using SabreTools.Core.Tools;
|
||||
using SabreTools.DatItems;
|
||||
using SabreTools.DatItems.Formats;
|
||||
@@ -1206,57 +1205,6 @@ namespace SabreTools.DatFiles
|
||||
|
||||
#endregion
|
||||
|
||||
// TODO: All internal, can this be put into a better location?
|
||||
#region Filtering
|
||||
|
||||
/// <summary>
|
||||
/// Execute all filters in a filter runner on the items in the dictionary
|
||||
/// </summary>
|
||||
/// <param name="filterRunner">Preconfigured filter runner to use</param>
|
||||
internal void ExecuteFilters(FilterRunner filterRunner)
|
||||
{
|
||||
List<string> keys = [.. SortedKeys];
|
||||
#if NET452_OR_GREATER || NETCOREAPP
|
||||
Parallel.ForEach(keys, Core.Globals.ParallelOptions, key =>
|
||||
#elif NET40_OR_GREATER
|
||||
Parallel.ForEach(keys, key =>
|
||||
#else
|
||||
foreach (var key in keys)
|
||||
#endif
|
||||
{
|
||||
ExecuteFilterOnBucket(filterRunner, key);
|
||||
#if NET40_OR_GREATER || NETCOREAPP
|
||||
});
|
||||
#else
|
||||
}
|
||||
#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)
|
||||
{
|
||||
var items = GetItemsForBucket(bucketName);
|
||||
if (items == null)
|
||||
return;
|
||||
|
||||
// Filter all items in the current key
|
||||
List<long> newItems = [];
|
||||
foreach (var item in items)
|
||||
{
|
||||
if (item.Value.PassesFilterDB(filterRunner))
|
||||
newItems.Add(item.Key);
|
||||
}
|
||||
|
||||
// Set the value in the key to the new set
|
||||
_buckets[bucketName] = newItems;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Statistics
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user