Sync implementation split

This commit is contained in:
Matt Nadareski
2025-01-13 23:37:32 -05:00
parent d06379d92f
commit 020b7363a5

View File

@@ -845,26 +845,7 @@ namespace SabreTools.DatFiles
foreach (var key in keys) foreach (var key in keys)
#endif #endif
{ {
List<DatItem>? items = this[key]; ExecuteFilterOnBucket(filterRunner, key);
if (items == null)
#if NET40_OR_GREATER || NETCOREAPP
return;
#else
continue;
#endif
// Filter all items in the current key
List<DatItem> 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);
#if NET40_OR_GREATER || NETCOREAPP #if NET40_OR_GREATER || NETCOREAPP
}); });
#else #else
@@ -872,6 +853,30 @@ namespace SabreTools.DatFiles
#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)
{
List<DatItem>? items = GetItemsForBucket(bucketName);
if (items == null)
return;
// Filter all items in the current key
List<DatItem> 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 #endregion
#region Statistics #region Statistics