diff --git a/Src/IronPython/Runtime/Binding/PythonExtensionBinder.cs b/Src/IronPython/Runtime/Binding/PythonExtensionBinder.cs index 19546f2ea..9096f0574 100644 --- a/Src/IronPython/Runtime/Binding/PythonExtensionBinder.cs +++ b/Src/IronPython/Runtime/Binding/PythonExtensionBinder.cs @@ -24,7 +24,7 @@ public PythonExtensionBinder(PythonBinder binder, ExtensionMethodSet extensionMe public override MemberGroup GetMember(MemberRequestKind actionKind, Type type, string name) { var res = base.GetMember(actionKind, type, name); if (res.Count == 0) { - List trackers = new List(); + HashSet trackers = new HashSet(); foreach (var method in _extMethodSet.GetExtensionMethods(name)) { var parameters = method.GetParameters(); @@ -35,11 +35,11 @@ public override MemberGroup GetMember(MemberRequestKind actionKind, Type type, s var paramType = parameters[0].ParameterType; if (IsApplicableExtensionMethod(type, paramType)) { - trackers.Add(MemberTracker.FromMemberInfo(method, paramType)); + (trackers ??= new HashSet()).Add(MemberTracker.FromMemberInfo(method, paramType)); } } - if (trackers.Count > 0) { + if (trackers is not null) { return new MemberGroup(trackers.ToArray()); } }