Skip to content

Commit 5e5833c

Browse files
committed
Save reiterating over unreachables
1 parent 97f762a commit 5e5833c

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Modules/gcmodule.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,13 +1125,15 @@ finalize_garbage(PyThreadState *tstate, PyGC_Head *collectable)
11251125
* tricky business as the lists can be changing and we don't know which
11261126
* objects may be freed. It is possible I screwed something up here.
11271127
*/
1128-
static void
1128+
static uintptr_t
11291129
delete_garbage(PyThreadState *tstate, GCState *gcstate,
11301130
PyGC_Head *collectable, PyGC_Head *old)
11311131
{
1132+
uintptr_t deleted = 0;
11321133
assert(!_PyErr_Occurred(tstate));
11331134

11341135
while (!gc_list_is_empty(collectable)) {
1136+
deleted++;
11351137
PyGC_Head *gc = GC_NEXT(collectable);
11361138
PyObject *op = FROM_GC(gc);
11371139

@@ -1162,6 +1164,7 @@ delete_garbage(PyThreadState *tstate, GCState *gcstate,
11621164
gc_list_move(gc, old);
11631165
}
11641166
}
1167+
return deleted;
11651168
}
11661169

11671170
/* Clear all free lists
@@ -1639,8 +1642,7 @@ gc_collect_region(PyThreadState *tstate,
16391642
* the reference cycles to be broken. It may also cause some objects
16401643
* in finalizers to be freed.
16411644
*/
1642-
stats->collected += gc_list_size(&final_unreachable);
1643-
delete_garbage(tstate, gcstate, &final_unreachable, to);
1645+
stats->collected += delete_garbage(tstate, gcstate, &final_unreachable, to);
16441646
validate_consistent_old_space(to);
16451647

16461648
/* Collect statistics on uncollectable objects found and print

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy