Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions src/core/IronPython/Compiler/Ast/ClassDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -407,10 +407,10 @@ public static string[] FindNames(FunctionDefinition function) {

var finder = new SelfNameFinder(function, parameters[0]);
function.Body.Walk(finder);
return ArrayUtils.ToArray(finder._names.Keys);
return [..finder._names];
}

private readonly Dictionary<string, bool> _names = new Dictionary<string, bool>(StringComparer.Ordinal);
private readonly HashSet<string> _names = new(StringComparer.Ordinal);

private bool IsSelfReference(Expression expr) {
return expr is NameExpression ne
Expand All @@ -426,7 +426,7 @@ public override bool Walk(AssignmentStatement node) {
foreach (Expression lhs in node.Left) {
if (lhs is MemberExpression me) {
if (IsSelfReference(me.Target)) {
_names[me.Name] = true;
_names.Add(me.Name);
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/core/IronPython/Runtime/Types/NewTypeMaker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ private Dictionary<string, string[]> ImplementType() {

ImplementProtectedFieldAccessors(specialNames);

Dictionary<Type, bool> doneTypes = new Dictionary<Type, bool>();
var doneTypes = new HashSet<Type>();
foreach (Type interfaceType in _interfaceTypes) {
DoInterfaceType(interfaceType, doneTypes, specialNames);
}
Expand Down Expand Up @@ -364,15 +364,15 @@ private static bool CanOverrideMethod(MethodInfo mi) {
return true;
}

private void DoInterfaceType(Type interfaceType, Dictionary<Type, bool> doneTypes, Dictionary<string, string[]> specialNames) {
private void DoInterfaceType(Type interfaceType, HashSet<Type> doneTypes, Dictionary<string, string[]> specialNames) {
if (interfaceType == typeof(IDynamicMetaObjectProvider)) {
// very tricky, we'll handle it when we're creating
// our own IDynamicMetaObjectProvider interface
return;
}

if (doneTypes.ContainsKey(interfaceType)) return;
doneTypes.Add(interfaceType, true);
if (doneTypes.Contains(interfaceType)) return;
doneTypes.Add(interfaceType);
OverrideMethods(interfaceType, specialNames);

foreach (Type t in interfaceType.GetInterfaces()) {
Expand Down
6 changes: 3 additions & 3 deletions src/extensions/IronPython.SQLite/Connection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public string isolation_level
private List<WeakReference> statements = new List<WeakReference>();
private int created_statements = 0;

private Dictionary<object, object> function_pinboard = new Dictionary<object, object>();
private readonly HashSet<object> function_pinboard = new();

internal Sqlite3.sqlite3 db;

Expand Down Expand Up @@ -286,7 +286,7 @@ public void create_function(CodeContext context, string name, int narg, object f
if(rc != Sqlite3.SQLITE_OK)
throw MakeOperationalError("Error creating function");
else
this.function_pinboard[func] = null;
this.function_pinboard.Add(func);
}

private static void callUserFunction(Sqlite3.sqlite3_context ctx, int argc, sqlite3_value[] argv)
Expand Down Expand Up @@ -459,7 +459,7 @@ public void create_aggregate(CodeContext context, string name, int n_arg, object
if(rc != Sqlite3.SQLITE_OK)
throw MakeOperationalError("Error creating aggregate");
else
this.function_pinboard[aggregate_class] = null;
this.function_pinboard.Add(aggregate_class);
}

#endregion
Expand Down