diff options
author | Thomas Wouters <thomas@python.org> | 2006-04-15 21:47:09 +0000 |
---|---|---|
committer | Thomas Wouters <thomas@python.org> | 2006-04-15 21:47:09 +0000 |
commit | c6e55068cad6f2178981eec4f0a0a583b8bba21a (patch) | |
tree | 19a89bbe082dadc70c1413030e5a5b8dacac757c /Objects/listobject.c | |
parent | 447d095976fd532bf1882bf7afeb52473ff8673c (diff) | |
download | cpython-git-c6e55068cad6f2178981eec4f0a0a583b8bba21a.tar.gz |
Use Py_VISIT in all tp_traverse methods, instead of traversing manually or
using a custom, nearly-identical macro. This probably changes how some of
these functions are compiled, which may result in fractionally slower (or
faster) execution. Considering the nature of traversal, visiting much of the
address space in unpredictable patterns, I'd argue the code readability and
maintainability is well worth it ;P
Diffstat (limited to 'Objects/listobject.c')
-rw-r--r-- | Objects/listobject.c | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/Objects/listobject.c b/Objects/listobject.c index 1debd23791..78961f33da 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -2276,14 +2276,8 @@ list_traverse(PyListObject *o, visitproc visit, void *arg) Py_ssize_t i; PyObject *x; - for (i = o->ob_size; --i >= 0; ) { - x = o->ob_item[i]; - if (x != NULL) { - int err = visit(x, arg); - if (err) - return err; - } - } + for (i = o->ob_size; --i >= 0; ) + Py_VISIT(o->ob_item[i]); return 0; } @@ -2779,9 +2773,8 @@ listiter_dealloc(listiterobject *it) static int listiter_traverse(listiterobject *it, visitproc visit, void *arg) { - if (it->it_seq == NULL) - return 0; - return visit((PyObject *)it->it_seq, arg); + Py_VISIT(it->it_seq); + return 0; } static PyObject * @@ -2898,9 +2891,8 @@ listreviter_dealloc(listreviterobject *it) static int listreviter_traverse(listreviterobject *it, visitproc visit, void *arg) { - if (it->it_seq == NULL) - return 0; - return visit((PyObject *)it->it_seq, arg); + Py_VISIT(it->it_seq); + return 0; } static PyObject * |