Skip to content

Commit

Permalink
Use HashSet instead of List for _virtual_methods (dotnet/linker#2976)
Browse files Browse the repository at this point in the history
* Use a HashSet instead of List for MarkStep._virtual_methods

Commit migrated from dotnet/linker@6252a21
  • Loading branch information
jtschuster authored Aug 16, 2022
1 parent f30a633 commit 341829d
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/tools/illink/src/linker/Linker.Steps/MarkStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ protected LinkContext Context {
}

protected Queue<(MethodDefinition, DependencyInfo, MessageOrigin)> _methods;
protected List<(MethodDefinition, MarkScopeStack.Scope)> _virtual_methods;
protected HashSet<(MethodDefinition, MarkScopeStack.Scope)> _virtual_methods;
protected Queue<AttributeProviderPair> _assemblyLevelAttributes;
readonly List<AttributeProviderPair> _ivt_attributes;
protected Queue<(AttributeProviderPair, DependencyInfo, MarkScopeStack.Scope)> _lateMarkedAttributes;
Expand Down Expand Up @@ -224,7 +224,7 @@ internal DynamicallyAccessedMembersTypeHierarchy DynamicallyAccessedMembersTypeH
public MarkStep ()
{
_methods = new Queue<(MethodDefinition, DependencyInfo, MessageOrigin)> ();
_virtual_methods = new List<(MethodDefinition, MarkScopeStack.Scope)> ();
_virtual_methods = new HashSet<(MethodDefinition, MarkScopeStack.Scope)> ();
_assemblyLevelAttributes = new Queue<AttributeProviderPair> ();
_ivt_attributes = new List<AttributeProviderPair> ();
_lateMarkedAttributes = new Queue<(AttributeProviderPair, DependencyInfo, MarkScopeStack.Scope)> ();
Expand Down Expand Up @@ -3352,7 +3352,6 @@ void MarkBaseMethods (MethodDefinition method)
if (base_method.DeclaringType.IsInterface && !method.DeclaringType.IsInterface) {
// These are all virtual, no need to check IsVirtual before adding to list
_virtual_methods.Add ((base_method, ScopeStack.CurrentScope));
// _virtual_methods is a list and might have duplicates, but it's mostly just used for override validation, so it shouldn't matter
continue;
}

Expand Down

0 comments on commit 341829d

Please sign in to comment.