diff options
author | Guido van Rossum <guido@python.org> | 2001-12-06 02:35:58 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2001-12-06 02:35:58 (GMT) |
commit | 14227b4dd41c1dd6cf2ff5b81ad5197b205080ab (patch) | |
tree | fac4ef589a0312af1dd20e88fe9aa10866db1efd | |
parent | 101de912d3613132b2eb80c802551006b3a11624 (diff) | |
download | cpython-14227b4dd41c1dd6cf2ff5b81ad5197b205080ab.zip cpython-14227b4dd41c1dd6cf2ff5b81ad5197b205080ab.tar.gz cpython-14227b4dd41c1dd6cf2ff5b81ad5197b205080ab.tar.bz2 |
The previous checkin to clear __slots__ variables did a little bit of
the work each time it found another base class. All the work is
contiguous, so we might as well do it all at once at the end.
-rw-r--r-- | Objects/typeobject.c | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 37ab4cb..6243e81 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -304,7 +304,7 @@ call_finalizer(PyObject *self) static void subtype_dealloc(PyObject *self) { - PyTypeObject *type, *base, *temp; + PyTypeObject *type, *base; destructor f; /* This exists so we can DECREF self->ob_type */ @@ -314,28 +314,28 @@ subtype_dealloc(PyObject *self) /* Find the nearest base with a different tp_dealloc */ type = self->ob_type; - base = type; + base = type->tp_base; while ((f = base->tp_dealloc) == subtype_dealloc) { - temp = base; base = base->tp_base; assert(base); - /* While we're at it, clear __slots__ variables */ - if (temp->tp_basicsize != base->tp_basicsize && - temp->tp_itemsize == 0) - { - char *addr = ((char *)self); - char *p = addr + base->tp_basicsize; - char *q = addr + temp->tp_basicsize; - for (; p < q; p += sizeof(PyObject *)) { - PyObject **pp; - if (p == addr + type->tp_dictoffset || - p == addr + type->tp_weaklistoffset) - continue; - pp = (PyObject **)p; - if (*pp != NULL) { - Py_DECREF(*pp); - *pp = NULL; - } + } + + /* Clear __slots__ variables */ + if (type->tp_basicsize != base->tp_basicsize && + type->tp_itemsize == 0) + { + char *addr = ((char *)self); + char *p = addr + base->tp_basicsize; + char *q = addr + type->tp_basicsize; + for (; p < q; p += sizeof(PyObject *)) { + PyObject **pp; + if (p == addr + type->tp_dictoffset || + p == addr + type->tp_weaklistoffset) + continue; + pp = (PyObject **)p; + if (*pp != NULL) { + Py_DECREF(*pp); + *pp = NULL; } } } |