summaryrefslogtreecommitdiffstats
path: root/Objects/iterobject.c
diff options
context:
space:
mode:
authorThomas Wouters <thomas@python.org>2006-04-15 21:47:09 (GMT)
committerThomas Wouters <thomas@python.org>2006-04-15 21:47:09 (GMT)
commitc6e55068cad6f2178981eec4f0a0a583b8bba21a (patch)
tree19a89bbe082dadc70c1413030e5a5b8dacac757c /Objects/iterobject.c
parent447d095976fd532bf1882bf7afeb52473ff8673c (diff)
downloadcpython-c6e55068cad6f2178981eec4f0a0a583b8bba21a.zip
cpython-c6e55068cad6f2178981eec4f0a0a583b8bba21a.tar.gz
cpython-c6e55068cad6f2178981eec4f0a0a583b8bba21a.tar.bz2
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/iterobject.c')
-rw-r--r--Objects/iterobject.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/Objects/iterobject.c b/Objects/iterobject.c
index 14cacc6..cf839f4 100644
--- a/Objects/iterobject.c
+++ b/Objects/iterobject.c
@@ -38,9 +38,8 @@ iter_dealloc(seqiterobject *it)
static int
iter_traverse(seqiterobject *it, visitproc visit, void *arg)
{
- if (it->it_seq == NULL)
- return 0;
- return visit(it->it_seq, arg);
+ Py_VISIT(it->it_seq);
+ return 0;
}
static PyObject *
@@ -162,11 +161,8 @@ calliter_dealloc(calliterobject *it)
static int
calliter_traverse(calliterobject *it, visitproc visit, void *arg)
{
- int err;
- if (it->it_callable != NULL && (err = visit(it->it_callable, arg)))
- return err;
- if (it->it_sentinel != NULL && (err = visit(it->it_sentinel, arg)))
- return err;
+ Py_VISIT(it->it_callable);
+ Py_VISIT(it->it_sentinel);
return 0;
}