summaryrefslogtreecommitdiffstats
path: root/Modules/cPickle.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 /Modules/cPickle.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 'Modules/cPickle.c')
-rw-r--r--Modules/cPickle.c51
1 files changed, 17 insertions, 34 deletions
diff --git a/Modules/cPickle.c b/Modules/cPickle.c
index 1d99fcb..18df599 100644
--- a/Modules/cPickle.c
+++ b/Modules/cPickle.c
@@ -2909,22 +2909,14 @@ Pickler_dealloc(Picklerobject *self)
static int
Pickler_traverse(Picklerobject *self, visitproc visit, void *arg)
{
- int err;
-#define VISIT(SLOT) \
- if (SLOT) { \
- err = visit((PyObject *)(SLOT), arg); \
- if (err) \
- return err; \
- }
- VISIT(self->write);
- VISIT(self->memo);
- VISIT(self->fast_memo);
- VISIT(self->arg);
- VISIT(self->file);
- VISIT(self->pers_func);
- VISIT(self->inst_pers_func);
- VISIT(self->dispatch_table);
-#undef VISIT
+ Py_VISIT(self->write);
+ Py_VISIT(self->memo);
+ Py_VISIT(self->fast_memo);
+ Py_VISIT(self->arg);
+ Py_VISIT(self->file);
+ Py_VISIT(self->pers_func);
+ Py_VISIT(self->inst_pers_func);
+ Py_VISIT(self->dispatch_table);
return 0;
}
@@ -5258,24 +5250,15 @@ Unpickler_dealloc(Unpicklerobject *self)
static int
Unpickler_traverse(Unpicklerobject *self, visitproc visit, void *arg)
{
- int err;
-
-#define VISIT(SLOT) \
- if (SLOT) { \
- err = visit((PyObject *)(SLOT), arg); \
- if (err) \
- return err; \
- }
- VISIT(self->readline);
- VISIT(self->read);
- VISIT(self->file);
- VISIT(self->memo);
- VISIT(self->stack);
- VISIT(self->pers_func);
- VISIT(self->arg);
- VISIT(self->last_string);
- VISIT(self->find_class);
-#undef VISIT
+ Py_VISIT(self->readline);
+ Py_VISIT(self->read);
+ Py_VISIT(self->file);
+ Py_VISIT(self->memo);
+ Py_VISIT(self->stack);
+ Py_VISIT(self->pers_func);
+ Py_VISIT(self->arg);
+ Py_VISIT(self->last_string);
+ Py_VISIT(self->find_class);
return 0;
}