summaryrefslogtreecommitdiffstats
path: root/Objects/tupleobject.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/tupleobject.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/tupleobject.c')
-rw-r--r--Objects/tupleobject.c18
1 files changed, 5 insertions, 13 deletions
diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c
index 10b7aaf..2161ab9 100644
--- a/Objects/tupleobject.c
+++ b/Objects/tupleobject.c
@@ -438,16 +438,9 @@ static int
tupletraverse(PyTupleObject *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;
}
@@ -802,9 +795,8 @@ tupleiter_dealloc(tupleiterobject *it)
static int
tupleiter_traverse(tupleiterobject *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 *