summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2012-10-04 19:53:50 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2012-10-04 19:53:50 (GMT)
commit90db9c47dca4d105835386fc57d46472b0836820 (patch)
tree345440b7ef8e54420ff06e87514f0540256e7958 /Objects
parent6964f4b790470e1dcefb77d51166268e6676d068 (diff)
downloadcpython-90db9c47dca4d105835386fc57d46472b0836820.zip
cpython-90db9c47dca4d105835386fc57d46472b0836820.tar.gz
cpython-90db9c47dca4d105835386fc57d46472b0836820.tar.bz2
Enable also ptr==ptr optimization in PyUnicode_Compare()
It was already implemented in PyUnicode_RichCompare()
Diffstat (limited to 'Objects')
-rw-r--r--Objects/unicodeobject.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 98b10e9..b84d888 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -10445,6 +10445,10 @@ unicode_compare(PyObject *str1, PyObject *str2)
void *data1, *data2;
Py_ssize_t len1, len2, i;
+ /* a string is equal to itself */
+ if (str1 == str2)
+ return 0;
+
kind1 = PyUnicode_KIND(str1);
kind2 = PyUnicode_KIND(str2);
data1 = PyUnicode_DATA(str1);
@@ -10531,10 +10535,7 @@ PyUnicode_RichCompare(PyObject *left, PyObject *right, int op)
return Py_True;
}
}
- if (left == right)
- result = 0;
- else
- result = unicode_compare(left, right);
+ result = unicode_compare(left, right);
/* Convert the return value to a Boolean */
switch (op) {