From 6252a2194dd32911db2c0669fc818555687d5570 Mon Sep 17 00:00:00 2001 From: Jackson Schuster <36744439+jtschuster@users.noreply.github.com> Date: Mon, 15 Aug 2022 17:39:01 -0700 Subject: [PATCH] Use HashSet instead of List for _virtual_methods (#2976) * Use a HashSet instead of List for MarkStep._virtual_methods --- src/linker/Linker.Steps/MarkStep.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/linker/Linker.Steps/MarkStep.cs b/src/linker/Linker.Steps/MarkStep.cs index 66733c12a402..81b4b5909001 100644 --- a/src/linker/Linker.Steps/MarkStep.cs +++ b/src/linker/Linker.Steps/MarkStep.cs @@ -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 _assemblyLevelAttributes; readonly List _ivt_attributes; protected Queue<(AttributeProviderPair, DependencyInfo, MarkScopeStack.Scope)> _lateMarkedAttributes; @@ -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 (); _ivt_attributes = new List (); _lateMarkedAttributes = new Queue<(AttributeProviderPair, DependencyInfo, MarkScopeStack.Scope)> (); @@ -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; }