Skip to content

Commit 20c5732

Browse files
committed
Only clean up on Capacity change
1 parent 7a92772 commit 20c5732

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/core/IronPython/Runtime/Types/PythonType.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2498,7 +2498,9 @@ private void AddSubType(PythonType subtype) {
24982498
}
24992499

25002500
lock (_subtypesLock) {
2501-
_subtypes.RemoveAll(x => !x.TryGetTarget(out _)); // remove dead entries
2501+
if (_subtypes.Count == _subtypes.Capacity) {
2502+
_subtypes.RemoveAll(x => !x.TryGetTarget(out _)); // remove dead entries
2503+
}
25022504
_subtypes.Add(new WeakReference<PythonType>(subtype));
25032505
}
25042506
}

0 commit comments

Comments
 (0)