summaryrefslogtreecommitdiffstats
path: root/Objects/unicodeobject.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2013-11-04 10:08:10 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2013-11-04 10:08:10 (GMT)
commitc8bc5377ac59c6e6af5c0e925fa0af7d9df7ebc0 (patch)
treef1ebf7f7213b38f578e9bee21b168057944e7a7d /Objects/unicodeobject.c
parent63d867e95c377ad91247051ab85a6294ed14cb35 (diff)
downloadcpython-c8bc5377ac59c6e6af5c0e925fa0af7d9df7ebc0.zip
cpython-c8bc5377ac59c6e6af5c0e925fa0af7d9df7ebc0.tar.gz
cpython-c8bc5377ac59c6e6af5c0e925fa0af7d9df7ebc0.tar.bz2
Issue #16286: write a new subfunction bytes_compare_eq()
* cleanup bytes_richcompare() * PyUnicode_RichCompare(): replace a test with a XOR
Diffstat (limited to 'Objects/unicodeobject.c')
-rw-r--r--Objects/unicodeobject.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 01e5355..17ae481 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -10526,7 +10526,7 @@ unicode_compare(PyObject *str1, PyObject *str2)
#undef COMPARE
}
-static int
+Py_LOCAL(int)
unicode_compare_eq(PyObject *str1, PyObject *str2)
{
int kind;
@@ -10630,10 +10630,8 @@ PyUnicode_RichCompare(PyObject *left, PyObject *right, int op)
if (op == Py_EQ || op == Py_NE) {
result = unicode_compare_eq(left, right);
- if (op == Py_EQ)
- v = TEST_COND(result);
- else
- v = TEST_COND(!result);
+ result ^= (op == Py_NE);
+ v = TEST_COND(result);
}
else {
result = unicode_compare(left, right);