diff --git a/SabreTools.DatFiles/DatFile.Filtering.cs b/SabreTools.DatFiles/DatFile.Filtering.cs
index b57ce9f0..2211a486 100644
--- a/SabreTools.DatFiles/DatFile.Filtering.cs
+++ b/SabreTools.DatFiles/DatFile.Filtering.cs
@@ -191,13 +191,12 @@ namespace SabreTools.DatFiles
/// Applies to
private void ExecuteFiltersImpl(FilterRunner filterRunner)
{
- List keys = [.. Items.SortedKeys];
#if NET452_OR_GREATER || NETCOREAPP
- Parallel.ForEach(keys, Core.Globals.ParallelOptions, key =>
+ Parallel.ForEach(Items.SortedKeys, Core.Globals.ParallelOptions, key =>
#elif NET40_OR_GREATER
- Parallel.ForEach(keys, key =>
+ Parallel.ForEach(Items.SortedKeys, key =>
#else
- foreach (var key in keys)
+ foreach (var key in Items.SortedKeys)
#endif
{
ExecuteFilterOnBucket(filterRunner, key);
diff --git a/SabreTools.DatFiles/DatFile.Splitting.cs b/SabreTools.DatFiles/DatFile.Splitting.cs
index d2be5f10..30259faf 100644
--- a/SabreTools.DatFiles/DatFile.Splitting.cs
+++ b/SabreTools.DatFiles/DatFile.Splitting.cs
@@ -240,10 +240,7 @@ namespace SabreTools.DatFiles
///
private void AddItemsFromChildrenImpl(bool subfolder, bool skipDedup)
{
- List buckets = [.. Items.SortedKeys];
- buckets.Sort();
-
- foreach (string bucket in buckets)
+ foreach (string bucket in Items.SortedKeys)
{
// If the bucket has no items in it
List items = GetItemsForBucket(bucket);
@@ -503,10 +500,7 @@ namespace SabreTools.DatFiles
///
private void AddItemsFromCloneOfParentImpl()
{
- List buckets = [.. Items.SortedKeys];
- buckets.Sort();
-
- foreach (string bucket in buckets)
+ foreach (string bucket in Items.SortedKeys)
{
// If the bucket has no items in it
List items = GetItemsForBucket(bucket);
@@ -625,10 +619,7 @@ namespace SabreTools.DatFiles
private bool AddItemsFromDevicesImpl(bool deviceOnly, bool useSlotOptions)
{
bool foundnew = false;
- List buckets = [.. Items.SortedKeys];
- buckets.Sort();
-
- foreach (string bucket in buckets)
+ foreach (string bucket in Items.SortedKeys)
{
// If the bucket doesn't have items
List datItems = GetItemsForBucket(bucket);
@@ -937,10 +928,7 @@ namespace SabreTools.DatFiles
///
private void AddItemsFromRomOfParentImpl()
{
- List buckets = [.. Items.SortedKeys];
- buckets.Sort();
-
- foreach (string bucket in buckets)
+ foreach (string bucket in Items.SortedKeys)
{
// If the bucket has no items in it
List items = GetItemsForBucket(bucket);
@@ -1023,10 +1011,7 @@ namespace SabreTools.DatFiles
///
private void RemoveBiosAndDeviceSetsImpl()
{
- List buckets = [.. Items.SortedKeys];
- buckets.Sort();
-
- foreach (string bucket in buckets)
+ foreach (string bucket in Items.SortedKeys)
{
// If the bucket has no items in it
List items = GetItemsForBucket(bucket);
@@ -1093,10 +1078,7 @@ namespace SabreTools.DatFiles
///
private void RemoveItemsFromCloneOfChildImpl()
{
- List buckets = [.. Items.SortedKeys];
- buckets.Sort();
-
- foreach (string bucket in buckets)
+ foreach (string bucket in Items.SortedKeys)
{
// If the bucket has no items in it
List items = GetItemsForBucket(bucket);
@@ -1200,10 +1182,7 @@ namespace SabreTools.DatFiles
private void RemoveItemsFromRomOfChildImpl()
{
// Loop through the romof tags
- List buckets = [.. Items.SortedKeys];
- buckets.Sort();
-
- foreach (string bucket in buckets)
+ foreach (string bucket in Items.SortedKeys)
{
// If the bucket has no items in it
List items = GetItemsForBucket(bucket);
@@ -1281,10 +1260,7 @@ namespace SabreTools.DatFiles
/// Applies to
private void RemoveMachineRelationshipTagsImpl()
{
- List buckets = [.. Items.SortedKeys];
- buckets.Sort();
-
- foreach (string bucket in buckets)
+ foreach (string bucket in Items.SortedKeys)
{
// If the bucket has no items in it
var items = GetItemsForBucket(bucket);
diff --git a/SabreTools.DatFiles/DatFileTool.cs b/SabreTools.DatFiles/DatFileTool.cs
index b59977a9..5ef7bb62 100644
--- a/SabreTools.DatFiles/DatFileTool.cs
+++ b/SabreTools.DatFiles/DatFileTool.cs
@@ -311,13 +311,12 @@ namespace SabreTools.DatFiles
/// List of inputs to use for renaming
public static void ApplySuperDAT(DatFile datFile, List inputs)
{
- List keys = [.. datFile.Items.SortedKeys];
#if NET452_OR_GREATER || NETCOREAPP
- Parallel.ForEach(keys, Core.Globals.ParallelOptions, key =>
+ Parallel.ForEach(datFile.Items.SortedKeys, Core.Globals.ParallelOptions, key =>
#elif NET40_OR_GREATER
- Parallel.ForEach(keys, key =>
+ Parallel.ForEach(datFile.Items.SortedKeys, key =>
#else
- foreach (var key in keys)
+ foreach (var key in datFile.Items.SortedKeys)
#endif
{
List? items = datFile.GetItemsForBucket(key);
@@ -685,13 +684,12 @@ namespace SabreTools.DatFiles
intDat.BucketBy(ItemKey.CRC, DedupeType.Full);
// Then we compare against the base DAT
- List keys = [.. intDat.Items.SortedKeys];
#if NET452_OR_GREATER || NETCOREAPP
- Parallel.ForEach(keys, Core.Globals.ParallelOptions, key =>
+ Parallel.ForEach(intDat.Items.SortedKeys, Core.Globals.ParallelOptions, key =>
#elif NET40_OR_GREATER
- Parallel.ForEach(keys, key =>
+ Parallel.ForEach(intDat.Items.SortedKeys, key =>
#else
- foreach (var key in keys)
+ foreach (var key in intDat.Items.SortedKeys)
#endif
{
// Game Against uses game names
@@ -1522,8 +1520,7 @@ namespace SabreTools.DatFiles
private static void AddFromExisting(DatFile addTo, DatFile addFrom, bool delete = false)
{
// Get the list of keys from the DAT
- List keys = [.. addFrom.Items.SortedKeys];
- foreach (string key in keys)
+ foreach (string key in addFrom.Items.SortedKeys)
{
// Add everything from the key to the internal DAT
addFrom.GetItemsForBucket(key).ForEach(item => addTo.AddItem(item, statsOnly: false));
diff --git a/SabreTools.DatFiles/ItemDictionary.cs b/SabreTools.DatFiles/ItemDictionary.cs
index ef69c6a0..c5409899 100644
--- a/SabreTools.DatFiles/ItemDictionary.cs
+++ b/SabreTools.DatFiles/ItemDictionary.cs
@@ -50,29 +50,23 @@ namespace SabreTools.DatFiles
#endregion
- #region Publically available fields
-
- #region Keys
+ #region Fields
///
/// Get the keys in sorted order from the file dictionary
///
/// List of the keys in sorted order
[JsonIgnore, XmlIgnore]
- public List SortedKeys
+ public string[] SortedKeys
{
get
{
List keys = [.. _items.Keys];
keys.Sort(new NaturalComparer());
- return keys;
+ return [.. keys];
}
}
- #endregion
-
- #region Statistics
-
///
/// DAT statistics
///
@@ -81,8 +75,6 @@ namespace SabreTools.DatFiles
#endregion
- #endregion
-
#region Constructors
///
@@ -204,8 +196,7 @@ namespace SabreTools.DatFiles
///
internal void ClearEmpty()
{
- string[] keys = [.. SortedKeys];
- foreach (string key in keys)
+ foreach (string key in SortedKeys)
{
#if NET40_OR_GREATER || NETCOREAPP
// If the key doesn't exist, skip
@@ -240,8 +231,7 @@ namespace SabreTools.DatFiles
///
internal void ClearMarked()
{
- string[] keys = [.. SortedKeys];
- foreach (string key in keys)
+ foreach (string key in SortedKeys)
{
// Perform filtering on items
List list = GetItemsForBucket(key, filter: true);
@@ -664,13 +654,12 @@ namespace SabreTools.DatFiles
// Set the sorted type
_mergedBy = dedupeType;
- List keys = [.. SortedKeys];
#if NET452_OR_GREATER || NETCOREAPP
- Parallel.ForEach(keys, Core.Globals.ParallelOptions, key =>
+ Parallel.ForEach(SortedKeys, Core.Globals.ParallelOptions, key =>
#elif NET40_OR_GREATER
- Parallel.ForEach(keys, key =>
+ Parallel.ForEach(SortedKeys, key =>
#else
- foreach (var key in keys)
+ foreach (var key in SortedKeys)
#endif
{
// Get the possibly unsorted list
@@ -698,13 +687,12 @@ namespace SabreTools.DatFiles
///
private void PerformSorting()
{
- List keys = [.. SortedKeys];
#if NET452_OR_GREATER || NETCOREAPP
- Parallel.ForEach(keys, Core.Globals.ParallelOptions, key =>
+ Parallel.ForEach(SortedKeys, Core.Globals.ParallelOptions, key =>
#elif NET40_OR_GREATER
- Parallel.ForEach(keys, key =>
+ Parallel.ForEach(SortedKeys, key =>
#else
- foreach (var key in keys)
+ foreach (var key in SortedKeys)
#endif
{
// Get the possibly unsorted list
diff --git a/SabreTools.DatTools/Cleaner.cs b/SabreTools.DatTools/Cleaner.cs
index 4a6b8d38..16f626aa 100644
--- a/SabreTools.DatTools/Cleaner.cs
+++ b/SabreTools.DatTools/Cleaner.cs
@@ -152,8 +152,7 @@ namespace SabreTools.DatTools
/// Current DatFile object to run operations on
internal void CleanDatItems(DatFile datFile)
{
- List keys = [.. datFile.Items.SortedKeys];
- foreach (string key in keys)
+ foreach (string key in datFile.Items.SortedKeys)
{
// For every item in the current key
var items = datFile.GetItemsForBucket(key);
diff --git a/SabreTools.DatTools/Rebuilder.cs b/SabreTools.DatTools/Rebuilder.cs
index 4965df7e..d11cd596 100644
--- a/SabreTools.DatTools/Rebuilder.cs
+++ b/SabreTools.DatTools/Rebuilder.cs
@@ -109,8 +109,7 @@ namespace SabreTools.DatTools
datFile.BucketBy(ItemKey.SHA1, DedupeType.None);
// Then we want to loop through each of the hashes and see if we can rebuild
- List keys = [.. datFile.Items.SortedKeys];
- foreach (string hash in keys)
+ foreach (string hash in datFile.Items.SortedKeys)
{
// Pre-empt any issues that could arise from string length
if (hash.Length != Constants.SHA1Length)
diff --git a/SabreTools.DatTools/Statistics.cs b/SabreTools.DatTools/Statistics.cs
index 64c5d109..caaa8189 100644
--- a/SabreTools.DatTools/Statistics.cs
+++ b/SabreTools.DatTools/Statistics.cs
@@ -83,17 +83,17 @@ namespace SabreTools.DatTools
{
DatStatistics individualStats = datdata.DatStatistics;
individualStats.DisplayName = datdata.Header.GetStringFieldValue(DatHeader.FileNameKey);
- individualStats.MachineCount = datdata.Items.SortedKeys.Count;
+ individualStats.MachineCount = datdata.Items.SortedKeys.Length;
stats.Add(individualStats);
}
// Add single DAT stats to dir
dirStats.AddStatistics(datdata.DatStatistics);
- dirStats.GameCount += datdata.Items.SortedKeys.Count;
+ dirStats.GameCount += datdata.Items.SortedKeys.Length;
// Add single DAT stats to totals
totalStats.AddStatistics(datdata.DatStatistics);
- totalStats.GameCount += datdata.Items.SortedKeys.Count;
+ totalStats.GameCount += datdata.Items.SortedKeys.Length;
// Make sure to assign the new directory
lastdir = thisdir;
diff --git a/SabreTools.DatTools/Verification.cs b/SabreTools.DatTools/Verification.cs
index a4258f03..a983aa85 100644
--- a/SabreTools.DatTools/Verification.cs
+++ b/SabreTools.DatTools/Verification.cs
@@ -58,8 +58,7 @@ namespace SabreTools.DatTools
datFile.BucketBy(ItemKey.SHA1, DedupeType.None);
// Then we want to loop through each of the hashes and see if we can rebuild
- List keys = [.. datFile.Items.SortedKeys];
- foreach (string hash in keys)
+ foreach (string hash in datFile.Items.SortedKeys)
{
// Pre-empt any issues that could arise from string length
if (hash.Length != Constants.SHA1Length)
@@ -216,8 +215,7 @@ namespace SabreTools.DatTools
datFile.BucketBy(ItemKey.Machine, DedupeType.Full);
// Then mark items for removal
- List keys = [.. datFile.Items.SortedKeys];
- foreach (string key in keys)
+ foreach (string key in datFile.Items.SortedKeys)
{
List? items = datFile.GetItemsForBucket(key);
if (items == null)
diff --git a/SabreTools.DatTools/Writer.cs b/SabreTools.DatTools/Writer.cs
index 913caef2..799833ff 100644
--- a/SabreTools.DatTools/Writer.cs
+++ b/SabreTools.DatTools/Writer.cs
@@ -141,7 +141,7 @@ namespace SabreTools.DatTools
datFile.BucketBy(ItemKey.Machine, DedupeType.None, norename: true);
datFile.DatStatistics.DisplayName = datFile.Header.GetStringFieldValue(DatHeader.FileNameKey);
- datFile.DatStatistics.MachineCount = datFile.Items.SortedKeys.Count;
+ datFile.DatStatistics.MachineCount = datFile.Items.SortedKeys.Length;
List statsList =
[
diff --git a/SabreTools.Test/DatFiles/ItemDictionaryTests.cs b/SabreTools.Test/DatFiles/ItemDictionaryTests.cs
index eb8ba47a..4c61efaf 100644
--- a/SabreTools.Test/DatFiles/ItemDictionaryTests.cs
+++ b/SabreTools.Test/DatFiles/ItemDictionaryTests.cs
@@ -58,7 +58,7 @@ namespace SabreTools.Test.DatFiles
dict.AddItem(rom4, statsOnly: false);
dict.BucketBy(itemKey, DedupeType.None);
- Assert.Equal(expected, dict.SortedKeys.Count);
+ Assert.Equal(expected, dict.SortedKeys.Length);
}
[Fact]