Commit 89c42647 authored by Guido van Rossum's avatar Guido van Rossum

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.
parent 6c81e2a4
...@@ -332,14 +332,14 @@ binary_op1(PyObject *v, PyObject *w, const int op_slot) ...@@ -332,14 +332,14 @@ binary_op1(PyObject *v, PyObject *w, const int op_slot)
if (slotw == slotv) if (slotw == slotv)
slotw = NULL; 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 (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); x = slotv(v, w);
if (x != Py_NotImplemented) if (x != Py_NotImplemented)
return x; return x;
...@@ -442,14 +442,14 @@ ternary_op(PyObject *v, ...@@ -442,14 +442,14 @@ ternary_op(PyObject *v,
if (slotw == slotv) if (slotw == slotv)
slotw = NULL; 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 (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); x = slotv(v, w, z);
if (x != Py_NotImplemented) if (x != Py_NotImplemented)
return x; return x;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment