diff options
author | stratakis <cstratak@redhat.com> | 2017-11-02 10:32:54 (GMT) |
---|---|---|
committer | Nick Coghlan <ncoghlan@gmail.com> | 2017-11-02 10:32:54 (GMT) |
commit | e8b19656396381407ad91473af5da8b0d4346e88 (patch) | |
tree | 16638970d5014728a49808d0c80c4af0fe6ccb91 /Objects/tupleobject.c | |
parent | 4f469c096628af730b17798d0ebfd8925bfde836 (diff) | |
download | cpython-e8b19656396381407ad91473af5da8b0d4346e88.zip cpython-e8b19656396381407ad91473af5da8b0d4346e88.tar.gz cpython-e8b19656396381407ad91473af5da8b0d4346e88.tar.bz2 |
bpo-23699: Use a macro to reduce boilerplate code in rich comparison functions (GH-793)
Diffstat (limited to 'Objects/tupleobject.c')
-rw-r--r-- | Objects/tupleobject.c | 18 |
1 files changed, 1 insertions, 17 deletions
diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c index c150af8..35decd8 100644 --- a/Objects/tupleobject.c +++ b/Objects/tupleobject.c @@ -647,23 +647,7 @@ tuplerichcompare(PyObject *v, PyObject *w, int op) if (i >= vlen || i >= wlen) { /* No more items to compare -- compare sizes */ - int cmp; - PyObject *res; - switch (op) { - case Py_LT: cmp = vlen < wlen; break; - case Py_LE: cmp = vlen <= wlen; break; - case Py_EQ: cmp = vlen == wlen; break; - case Py_NE: cmp = vlen != wlen; break; - case Py_GT: cmp = vlen > wlen; break; - case Py_GE: cmp = vlen >= wlen; break; - default: return NULL; /* cannot happen */ - } - if (cmp) - res = Py_True; - else - res = Py_False; - Py_INCREF(res); - return res; + Py_RETURN_RICHCOMPARE(vlen, wlen, op); } /* We have an item that differs -- shortcuts for EQ/NE */ |