From 5ad2e5085bba7bd4f9d219edb45b57d2f2be4dd6 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Sat, 3 May 2025 23:36:15 -0400 Subject: [PATCH] Treat buckets during merge/split consistently --- SabreTools.DatFiles/DatFile.Splitting.cs | 28 +++++++++++++++--------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/SabreTools.DatFiles/DatFile.Splitting.cs b/SabreTools.DatFiles/DatFile.Splitting.cs index 39df2264..d4d8cab6 100644 --- a/SabreTools.DatFiles/DatFile.Splitting.cs +++ b/SabreTools.DatFiles/DatFile.Splitting.cs @@ -240,7 +240,8 @@ namespace SabreTools.DatFiles /// private void AddItemsFromChildrenImpl(bool subfolder, bool skipDedup) { - foreach (string bucket in Items.SortedKeys) + string[] buckets = [.. Items.SortedKeys]; + foreach (string bucket in buckets) { // If the bucket has no items in it List items = GetItemsForBucket(bucket); @@ -499,7 +500,8 @@ namespace SabreTools.DatFiles /// private void AddItemsFromCloneOfParentImpl() { - foreach (string bucket in Items.SortedKeys) + List buckets = [.. ItemsDB.SortedKeys]; + foreach (string bucket in buckets) { // If the bucket has no items in it List items = GetItemsForBucket(bucket); @@ -618,7 +620,9 @@ namespace SabreTools.DatFiles private bool AddItemsFromDevicesImpl(bool deviceOnly, bool useSlotOptions) { bool foundnew = false; - foreach (string bucket in Items.SortedKeys) + + List buckets = [.. ItemsDB.SortedKeys]; + foreach (string bucket in buckets) { // If the bucket doesn't have items List datItems = GetItemsForBucket(bucket); @@ -762,6 +766,7 @@ namespace SabreTools.DatFiles private bool AddItemsFromDevicesImplDB(bool deviceOnly, bool useSlotOptions) { bool foundnew = false; + List buckets = [.. ItemsDB.SortedKeys]; foreach (string bucket in buckets) { @@ -927,7 +932,8 @@ namespace SabreTools.DatFiles /// private void AddItemsFromRomOfParentImpl() { - foreach (string bucket in Items.SortedKeys) + List buckets = [.. ItemsDB.SortedKeys]; + foreach (string bucket in buckets) { // If the bucket has no items in it List items = GetItemsForBucket(bucket); @@ -1010,7 +1016,8 @@ namespace SabreTools.DatFiles /// private void RemoveBiosAndDeviceSetsImpl() { - foreach (string bucket in Items.SortedKeys) + List buckets = [.. ItemsDB.SortedKeys]; + foreach (string bucket in buckets) { // If the bucket has no items in it List items = GetItemsForBucket(bucket); @@ -1077,7 +1084,8 @@ namespace SabreTools.DatFiles /// private void RemoveItemsFromCloneOfChildImpl() { - foreach (string bucket in Items.SortedKeys) + List buckets = [.. ItemsDB.SortedKeys]; + foreach (string bucket in buckets) { // If the bucket has no items in it List items = GetItemsForBucket(bucket); @@ -1187,8 +1195,8 @@ namespace SabreTools.DatFiles /// private void RemoveItemsFromRomOfChildImpl() { - // Loop through the romof tags - foreach (string bucket in Items.SortedKeys) + List buckets = [.. ItemsDB.SortedKeys]; + foreach (string bucket in buckets) { // If the bucket has no items in it List items = GetItemsForBucket(bucket); @@ -1235,7 +1243,6 @@ namespace SabreTools.DatFiles /// private void RemoveItemsFromRomOfChildImplDB() { - // Loop through the romof tags List buckets = [.. ItemsDB.SortedKeys]; foreach (string bucket in buckets) { @@ -1273,7 +1280,8 @@ namespace SabreTools.DatFiles /// Applies to private void RemoveMachineRelationshipTagsImpl() { - foreach (string bucket in Items.SortedKeys) + List buckets = [.. ItemsDB.SortedKeys]; + foreach (string bucket in buckets) { // If the bucket has no items in it var items = GetItemsForBucket(bucket);