Inform the cycle-detector that the a weakref object no longer needs to be

tracked as soon as it is clear; this can decrease the number of roots for
the cycle detector sooner rather than later in applications which hold on
to weak references beyond the time of the invalidation.
This commit is contained in:
Fred Drake 2001-03-22 18:05:30 +00:00
parent 2c77355937
commit 82f1480d63
1 changed files with 1 additions and 1 deletions

View File

@ -59,6 +59,7 @@ clear_weakref(PyWeakReference *self)
if (self->wr_object != Py_None) {
PyWeakReference **list = GET_WEAKREFS_LISTPTR(self->wr_object);
PyObject_GC_Fini((PyObject *)self);
if (*list == self)
*list = self->wr_next;
self->wr_object = Py_None;
@ -78,7 +79,6 @@ static void
weakref_dealloc(PyWeakReference *self)
{
clear_weakref(self);
PyObject_GC_Fini((PyObject *)self);
self->wr_next = free_list;
free_list = self;
}