Skip to content

Commit

Permalink
fix #1747
Browse files Browse the repository at this point in the history
  • Loading branch information
zivmaor committed Sep 20, 2024
1 parent 9f4f13a commit 1a4759e
Showing 1 changed file with 25 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1498,39 +1498,42 @@ public static async Task<Dictionary<string, List<object>>> GetUnreferencedObject
mainWindow.SetProgressBar(null, "Assets", 0, assets.Count);
mainWindow.StartProgressBarUpdater();

var assetsPart = Partitioner.Create(0, assets.Count);

List<Dictionary<string, List<object>>> dicts = new();

await Task.Run(() =>
if (assets.Count != 0) // A Partitioner can't be created on an empty list.
{
Parallel.ForEach(assetsPart, (range) =>
{
var resultDict = new Dictionary<string, List<object>>();
var assetsPart = Partitioner.Create(0, assets.Count);

for (int i = range.Item1; i < range.Item2; i++)
await Task.Run(() =>
{
Parallel.ForEach(assetsPart, (range) =>
{
var asset = assets[i];
var assetReferences = GetReferencesOfObject(asset.Item1, data,
new HashSetTypesOverride(true, data.Code is null), true);
if (assetReferences is null)
var resultDict = new Dictionary<string, List<object>>();
for (int i = range.Item1; i < range.Item2; i++)
{
if (resultDict.TryGetValue(asset.Item2, out var list))
var asset = assets[i];
var assetReferences = GetReferencesOfObject(asset.Item1, data,
new HashSetTypesOverride(true, data.Code is null), true);
if (assetReferences is null)
{
list.Add(asset.Item1);
}
else
{
resultDict[asset.Item2] = new() { asset.Item1 };
if (resultDict.TryGetValue(asset.Item2, out var list))
{
list.Add(asset.Item1);
}
else
{
resultDict[asset.Item2] = new() { asset.Item1 };
}
}
}
mainWindow.IncrementProgressParallel();
}
mainWindow.IncrementProgressParallel();
}
dicts.Add(resultDict);
dicts.Add(resultDict);
});
});
});
}

Dictionary<string, int> outArrSizes = new();
foreach (var dict in dicts)
Expand Down

0 comments on commit 1a4759e

Please sign in to comment.