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,6 +332,7 @@ binary_op1(PyObject *v, PyObject *w, const int op_slot)
if (slotw == slotv)
slotw = NULL;
}
if (slotv) {
if (slotw && PyType_IsSubtype(w->ob_type, v->ob_type)) {
x = slotw(v, w);
if (x != Py_NotImplemented)
......@@ -339,7 +340,6 @@ binary_op1(PyObject *v, PyObject *w, const int op_slot)
Py_DECREF(x); /* can't do it */
slotw = NULL;
}
if (slotv) {
x = slotv(v, w);
if (x != Py_NotImplemented)
return x;
......@@ -442,6 +442,7 @@ ternary_op(PyObject *v,
if (slotw == slotv)
slotw = NULL;
}
if (slotv) {
if (slotw && PyType_IsSubtype(w->ob_type, v->ob_type)) {
x = slotw(v, w, z);
if (x != Py_NotImplemented)
......@@ -449,7 +450,6 @@ ternary_op(PyObject *v,
Py_DECREF(x); /* can't do it */
slotw = NULL;
}
if (slotv) {
x = slotv(v, w, z);
if (x != Py_NotImplemented)
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