summaryrefslogtreecommitdiff
path: root/Objects/funcobject.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
commitc6e55068cad6f2178981eec4f0a0a583b8bba21a (patch)
tree19a89bbe082dadc70c1413030e5a5b8dacac757c /Objects/funcobject.c
parent447d095976fd532bf1882bf7afeb52473ff8673c (diff)
downloadcpython-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/funcobject.c')
-rw-r--r--Objects/funcobject.c59
1 files changed, 12 insertions, 47 deletions
diff --git a/Objects/funcobject.c b/Objects/funcobject.c
index b86319cad8..59cb519507 100644
--- a/Objects/funcobject.c
+++ b/Objects/funcobject.c
@@ -466,47 +466,14 @@ func_repr(PyFunctionObject *op)
static int
func_traverse(PyFunctionObject *f, visitproc visit, void *arg)
{
- int err;
- if (f->func_code) {
- err = visit(f->func_code, arg);
- if (err)
- return err;
- }
- if (f->func_globals) {
- err = visit(f->func_globals, arg);
- if (err)
- return err;
- }
- if (f->func_module) {
- err = visit(f->func_module, arg);
- if (err)
- return err;
- }
- if (f->func_defaults) {
- err = visit(f->func_defaults, arg);
- if (err)
- return err;
- }
- if (f->func_doc) {
- err = visit(f->func_doc, arg);
- if (err)
- return err;
- }
- if (f->func_name) {
- err = visit(f->func_name, arg);
- if (err)
- return err;
- }
- if (f->func_dict) {
- err = visit(f->func_dict, arg);
- if (err)
- return err;
- }
- if (f->func_closure) {
- err = visit(f->func_closure, arg);
- if (err)
- return err;
- }
+ Py_VISIT(f->func_code);
+ Py_VISIT(f->func_globals);
+ Py_VISIT(f->func_module);
+ Py_VISIT(f->func_defaults);
+ Py_VISIT(f->func_doc);
+ Py_VISIT(f->func_name);
+ Py_VISIT(f->func_dict);
+ Py_VISIT(f->func_closure);
return 0;
}
@@ -647,9 +614,8 @@ cm_dealloc(classmethod *cm)
static int
cm_traverse(classmethod *cm, visitproc visit, void *arg)
{
- if (!cm->cm_callable)
- return 0;
- return visit(cm->cm_callable, arg);
+ Py_VISIT(cm->cm_callable);
+ return 0;
}
static int
@@ -806,9 +772,8 @@ sm_dealloc(staticmethod *sm)
static int
sm_traverse(staticmethod *sm, visitproc visit, void *arg)
{
- if (!sm->sm_callable)
- return 0;
- return visit(sm->sm_callable, arg);
+ Py_VISIT(sm->sm_callable);
+ return 0;
}
static int