mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Remove some multithreading to avoid thread contention
This commit is contained in:
@@ -160,44 +160,28 @@ namespace SabreTools.DatTools
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Apply removals to the item dictionary
|
/// Apply removals to the item dictionary
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// TODO: Does this need to be multi-threaded?
|
|
||||||
public void RemoveItemFields(ItemDictionary? itemDictionary)
|
public void RemoveItemFields(ItemDictionary? itemDictionary)
|
||||||
{
|
{
|
||||||
// If we have an invalid input, return
|
// If we have an invalid input, return
|
||||||
if (itemDictionary == null || (MachineFieldNames.Count == 0 && ItemFieldNames.Count == 0))
|
if (itemDictionary == null || (MachineFieldNames.Count == 0 && ItemFieldNames.Count == 0))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#if NET452_OR_GREATER || NETCOREAPP
|
|
||||||
Parallel.ForEach(itemDictionary.Keys, Core.Globals.ParallelOptions, key =>
|
|
||||||
#elif NET40_OR_GREATER
|
|
||||||
Parallel.ForEach(itemDictionary.Keys, key =>
|
|
||||||
#else
|
|
||||||
foreach (var key in itemDictionary.Keys)
|
foreach (var key in itemDictionary.Keys)
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
List<DatItem>? items = itemDictionary[key];
|
List<DatItem>? items = itemDictionary[key];
|
||||||
if (items == null)
|
if (items == null)
|
||||||
#if NET40_OR_GREATER || NETCOREAPP
|
|
||||||
return;
|
|
||||||
#else
|
|
||||||
continue;
|
continue;
|
||||||
#endif
|
|
||||||
|
|
||||||
for (int j = 0; j < items.Count; j++)
|
for (int j = 0; j < items.Count; j++)
|
||||||
{
|
{
|
||||||
RemoveFields(items[j]);
|
RemoveFields(items[j]);
|
||||||
}
|
}
|
||||||
#if NET40_OR_GREATER || NETCOREAPP
|
|
||||||
});
|
|
||||||
#else
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Apply removals to the item dictionary
|
/// Apply removals to the item dictionary
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// TODO: Does this need to be multi-threaded?
|
|
||||||
public void RemoveItemFieldsDB(ItemDictionaryDB? itemDictionary)
|
public void RemoveItemFieldsDB(ItemDictionaryDB? itemDictionary)
|
||||||
{
|
{
|
||||||
// If we have an invalid input, return
|
// If we have an invalid input, return
|
||||||
@@ -205,47 +189,23 @@ namespace SabreTools.DatTools
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Handle machine removals
|
// Handle machine removals
|
||||||
#if NET452_OR_GREATER || NETCOREAPP
|
|
||||||
Parallel.ForEach(itemDictionary.GetMachines(), Core.Globals.ParallelOptions, kvp =>
|
|
||||||
#elif NET40_OR_GREATER
|
|
||||||
Parallel.ForEach(itemDictionary.GetMachines(), kvp =>
|
|
||||||
#else
|
|
||||||
foreach (var kvp in itemDictionary.GetMachines())
|
foreach (var kvp in itemDictionary.GetMachines())
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
RemoveFields(kvp.Value);
|
RemoveFields(kvp.Value);
|
||||||
#if NET40_OR_GREATER || NETCOREAPP
|
|
||||||
});
|
|
||||||
#else
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
// Handle item removals
|
// Handle item removals
|
||||||
#if NET452_OR_GREATER || NETCOREAPP
|
|
||||||
Parallel.ForEach(ItemsDB.SortedKeys, Core.Globals.ParallelOptions, key =>
|
|
||||||
#elif NET40_OR_GREATER
|
|
||||||
Parallel.ForEach(ItemsDB.SortedKeys, key =>
|
|
||||||
#else
|
|
||||||
foreach (var key in itemDictionary.SortedKeys)
|
foreach (var key in itemDictionary.SortedKeys)
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
var items = itemDictionary.GetItemsForBucket(key);
|
var items = itemDictionary.GetItemsForBucket(key);
|
||||||
if (items == null)
|
if (items == null)
|
||||||
#if NET40_OR_GREATER || NETCOREAPP
|
|
||||||
return;
|
|
||||||
#else
|
|
||||||
continue;
|
continue;
|
||||||
#endif
|
|
||||||
|
|
||||||
foreach (var item in items.Values)
|
foreach (var item in items.Values)
|
||||||
{
|
{
|
||||||
RemoveFields(item);
|
RemoveFields(item);
|
||||||
}
|
}
|
||||||
#if NET40_OR_GREATER || NETCOREAPP
|
|
||||||
});
|
|
||||||
#else
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user