diff Objects/enumobject.c @ 37756:7b2e436a4a21 legacy-trunk

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
author Thomas Wouters <thomas@python.org>
date Sat, 15 Apr 2006 21:47:09 +0000
parents aeee85b6a5dd
children 1ad0568737f6
line wrap: on
line diff
--- a/Objects/enumobject.c	Sat Apr 15 21:41:56 2006 +0000
+++ b/Objects/enumobject.c	Sat Apr 15 21:47:09 2006 +0000
@@ -49,18 +49,8 @@
 static int
 enum_traverse(enumobject *en, visitproc visit, void *arg)
 {
-	int err;
-
-	if (en->en_sit) {
-		err = visit(en->en_sit, arg);
-		if (err)
-			return err;
-	}
-	if (en->en_result) {
-		err = visit(en->en_result, arg);
-		if (err)
-			return err;
-	}
+	Py_VISIT(en->en_sit);
+	Py_VISIT(en->en_result);
 	return 0;
 }
 
@@ -205,8 +195,7 @@
 static int
 reversed_traverse(reversedobject *ro, visitproc visit, void *arg)
 {
-	if (ro->seq)
-		return visit((PyObject *)(ro->seq), arg);
+	Py_VISIT(ro->seq);
 	return 0;
 }