[Python-checkins] CVS: python/dist/src/Objects abstract.c,2.82,2.83

Guido van Rossum gvanrossum@users.sourceforge.net
2001年10月01日 10:10:21 -0700


Update of /cvsroot/python/python/dist/src/Objects
In directory usw-pr-cvs1:/tmp/cvs-serv15540
Modified Files:
	abstract.c 
Log Message:
binary_op1(), ternary_op(): rearrange the code so that slotw is tested
(to see whether __rop__ should go before __op__) only when slotv is
set. This saves a test+branch when only slotw is set.
Index: abstract.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/abstract.c,v
retrieving revision 2.82
retrieving revision 2.83
diff -C2 -d -r2.82 -r2.83
*** abstract.c	2001年09月30日 05:58:41	2.82
--- abstract.c	2001年10月01日 17:10:18	2.83
***************
*** 333,344 ****
 			slotw = NULL;
 	}
- 	if (slotw && PyType_IsSubtype(w->ob_type, v->ob_type)) {
- 		x = slotw(v, w);
- 		if (x != Py_NotImplemented)
- 			return x;
- 		Py_DECREF(x); /* can't do it */
- 		slotw = NULL;
- 	}
 	if (slotv) {
 		x = slotv(v, w);
 		if (x != Py_NotImplemented)
--- 333,344 ----
 			slotw = NULL;
 	}
 	if (slotv) {
+ 		if (slotw && PyType_IsSubtype(w->ob_type, v->ob_type)) {
+ 			x = slotw(v, w);
+ 			if (x != Py_NotImplemented)
+ 				return x;
+ 			Py_DECREF(x); /* can't do it */
+ 			slotw = NULL;
+ 		}
 		x = slotv(v, w);
 		if (x != Py_NotImplemented)
***************
*** 443,454 ****
 			slotw = NULL;
 	}
- 	if (slotw && PyType_IsSubtype(w->ob_type, v->ob_type)) {
- 		x = slotw(v, w, z);
- 		if (x != Py_NotImplemented)
- 			return x;
- 		Py_DECREF(x); /* can't do it */
- 		slotw = NULL;
- 	}
 	if (slotv) {
 		x = slotv(v, w, z);
 		if (x != Py_NotImplemented)
--- 443,454 ----
 			slotw = NULL;
 	}
 	if (slotv) {
+ 		if (slotw && PyType_IsSubtype(w->ob_type, v->ob_type)) {
+ 			x = slotw(v, w, z);
+ 			if (x != Py_NotImplemented)
+ 				return x;
+ 			Py_DECREF(x); /* can't do it */
+ 			slotw = NULL;
+ 		}
 		x = slotv(v, w, z);
 		if (x != Py_NotImplemented)

AltStyle によって変換されたページ (->オリジナル) /