Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion ILRepack/Steps/ModuleInitializersRepackStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,26 @@ private void DemoteModuleInitializerMethodToNormalMethod(MethodDefinition initia
initializer.IsRuntimeSpecialName = false;
}

private Dictionary<string, AssemblyDefinition> ToDictionarySkipDuplicates(IEnumerable<AssemblyDefinition> assemblies)
{
var dict = new Dictionary<string, AssemblyDefinition>();
foreach (var assembly in assemblies)
{
if (!dict.ContainsKey(assembly.Name.Name))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assembly.Name.Name is repeated three times, it's good to extract a local variable and reuse it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sense, oh you already changed to the key. Nice!

{
dict[assembly.Name.Name] = assembly;
}
else
{
_logger.Verbose($"- Duplicate key found: {assembly.Name.Name} - skipping");
}
}
return dict;
}

private List<AssemblyDefinition> TopologicalSort(HashSet<AssemblyDefinition> assemblies)
{
var loadedAssemblies = assemblies.ToDictionary(a => a.Name.Name); // Ensure quick lookup
var loadedAssemblies = ToDictionarySkipDuplicates(assemblies); // Ensure quick lookup
var visited = new HashSet<AssemblyDefinition>();
var deepFirstAssemblies = new List<AssemblyDefinition>(assemblies.Count);

Expand Down