summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2001-10-01 17:10:18 (GMT)
committerGuido van Rossum <guido@python.org>2001-10-01 17:10:18 (GMT)
commit89c4264792da06293b197e14f581763f46138935 (patch)
treedeb196e01a8db9d38aeb9ad7c72745dc0b8cd0b8
parent6c81e2a44fd6ab5cacbb2e1d5c48933d65a58948 (diff)
downloadcpython-89c4264792da06293b197e14f581763f46138935.zip
cpython-89c4264792da06293b197e14f581763f46138935.tar.gz
cpython-89c4264792da06293b197e14f581763f46138935.tar.bz2
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.
-rw-r--r--Objects/abstract.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/Objects/abstract.c b/Objects/abstract.c
index 7a5305a..4891622 100644
--- a/Objects/abstract.c
+++ b/Objects/abstract.c
@@ -332,14 +332,14 @@ binary_op1(PyObject *v, PyObject *w, const int op_slot)
if (slotw == slotv)
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) {
+ 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)
return x;
@@ -442,14 +442,14 @@ ternary_op(PyObject *v,
if (slotw == slotv)
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) {
+ 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)
return x;