From 334ab130dab60e3591315c3e623263e5e702d8ca Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Thu, 16 Apr 2026 13:03:34 -0400 Subject: [PATCH] Remove unnecessary framework gating --- SabreTools.Metadata.DatFiles/ItemDatabase.cs | 52 +++----------------- 1 file changed, 7 insertions(+), 45 deletions(-) diff --git a/SabreTools.Metadata.DatFiles/ItemDatabase.cs b/SabreTools.Metadata.DatFiles/ItemDatabase.cs index 50454ef9..c6f30461 100644 --- a/SabreTools.Metadata.DatFiles/ItemDatabase.cs +++ b/SabreTools.Metadata.DatFiles/ItemDatabase.cs @@ -332,31 +332,15 @@ namespace SabreTools.Metadata.DatFiles if (bucketName is null) return []; -#if NET40_OR_GREATER || NETCOREAPP || NETSTANDARD2_0_OR_GREATER if (!_buckets.TryGetValue(bucketName, out var itemIds)) return []; -#else - if (!_buckets.ContainsKey(bucketName)) - return []; - - var itemIds = _buckets[bucketName]; -#endif var datItems = new Dictionary(); foreach (long itemId in itemIds) { // Ignore missing IDs -#if NET40_OR_GREATER || NETCOREAPP || NETSTANDARD2_0_OR_GREATER if (!_items.TryGetValue(itemId, out var datItem) || datItem is null) continue; -#else - if (!_items.ContainsKey(itemId)) - continue; - - var datItem = _items[itemId]; - if (datItem is null) - continue; -#endif if (!filter || !datItem.RemoveFlag) datItems[itemId] = datItem; @@ -370,17 +354,10 @@ namespace SabreTools.Metadata.DatFiles /// public Machine? GetMachine(long index) { -#if NET40_OR_GREATER || NETCOREAPP || NETSTANDARD2_0_OR_GREATER if (!_machines.TryGetValue(index, out var machine)) return null; return machine; -#else - if (!_machines.ContainsKey(index)) - return null; - - return _machines[index]; -#endif } /// @@ -468,15 +445,8 @@ namespace SabreTools.Metadata.DatFiles foreach (var index in list) { -#if NET40_OR_GREATER || NETCOREAPP || NETSTANDARD2_0_OR_GREATER if (!_items.TryGetValue(index, out var datItem) || datItem is null) continue; -#else - if (!_items.ContainsKey(index)) - continue; - - var datItem = _items[index]; -#endif RemoveItem(index); } @@ -870,20 +840,6 @@ namespace SabreTools.Metadata.DatFiles return output; } - /// - /// Ensure the key exists in the items dictionary - /// - private void EnsureBucketingKey(string key) - { - // If the key is missing from the dictionary, add it -#if NET40_OR_GREATER || NETCOREAPP || NETSTANDARD2_0_OR_GREATER - _buckets.GetOrAdd(key, []); -#else - if (!_buckets.ContainsKey(key)) - _buckets[key] = []; -#endif - } - /// /// Get the highest-order Field value that represents the statistics /// @@ -1018,7 +974,13 @@ namespace SabreTools.Metadata.DatFiles string? bucketKey = GetBucketKey(itemIndex, bucketBy, lower, norename); lock (bucketKey) { - EnsureBucketingKey(bucketKey); + // If the key is missing from the dictionary, add it +#if NET40_OR_GREATER || NETCOREAPP || NETSTANDARD2_0_OR_GREATER + _buckets.GetOrAdd(bucketKey, []); +#else + if (!_buckets.ContainsKey(bucketKey)) + _buckets[bucketKey] = []; +#endif #if NET40_OR_GREATER || NETCOREAPP || NETSTANDARD2_0_OR_GREATER if (!_buckets.TryGetValue(bucketKey, out var bucket) || bucket is null)