summaryrefslogtreecommitdiff
path: root/Modules/_csv.c
diff options
context:
space:
mode:
authorThomas Wouters <thomas@python.org>2006-04-15 21:47:09 +0000
committerThomas Wouters <thomas@python.org>2006-04-15 21:47:09 +0000
commit58c4139c1d6d525e89bb2e6233422e5d2fc38e14 (patch)
treea96de885b9502d53ae464132dc15b22f9279ee2d /Modules/_csv.c
parent2b18f142735ff17d4c6b8a4969b1b7b8a4cb83a7 (diff)
downloadcpython-58c4139c1d6d525e89bb2e6233422e5d2fc38e14.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 'Modules/_csv.c')
-rw-r--r--Modules/_csv.c35
1 files changed, 15 insertions, 20 deletions
diff --git a/Modules/_csv.c b/Modules/_csv.c
index 500d36e039..67d5d9f8fb 100644
--- a/Modules/_csv.c
+++ b/Modules/_csv.c
@@ -48,7 +48,16 @@ module instead.
} \
} while (0)
#endif
-
+#ifndef Py_VISIT
+#define Py_VISIT(op) \
+ do { \
+ if (op) { \
+ int vret = visit((PyObject *)(op), arg); \
+ if (vret) \
+ return vret; \
+ } \
+ } while (0)
+#endif
/* end 2.2 compatibility macros */
@@ -825,16 +834,9 @@ Reader_dealloc(ReaderObj *self)
static int
Reader_traverse(ReaderObj *self, visitproc visit, void *arg)
{
- int err;
-#define VISIT(SLOT) \
- if (SLOT) { \
- err = visit((PyObject *)(SLOT), arg); \
- if (err) \
- return err; \
- }
- VISIT(self->dialect);
- VISIT(self->input_iter);
- VISIT(self->fields);
+ Py_VISIT(self->dialect);
+ Py_VISIT(self->input_iter);
+ Py_VISIT(self->fields);
return 0;
}
@@ -1255,15 +1257,8 @@ Writer_dealloc(WriterObj *self)
static int
Writer_traverse(WriterObj *self, visitproc visit, void *arg)
{
- int err;
-#define VISIT(SLOT) \
- if (SLOT) { \
- err = visit((PyObject *)(SLOT), arg); \
- if (err) \
- return err; \
- }
- VISIT(self->dialect);
- VISIT(self->writeline);
+ Py_VISIT(self->dialect);
+ Py_VISIT(self->writeline);
return 0;
}