Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f0c7b2a

Browse files
committed
Issue #16286: remove duplicated identity check from unicode_compare()
Move the test to PyUnicode_Compare()
1 parent fd9e44d commit f0c7b2a

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

Objects/unicodeobject.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10428,10 +10428,6 @@ unicode_compare(PyObject *str1, PyObject *str2)
1042810428
void *data1, *data2;
1042910429
Py_ssize_t len1, len2, len;
1043010430

10431-
/* a string is equal to itself */
10432-
if (str1 == str2)
10433-
return 0;
10434-
1043510431
kind1 = PyUnicode_KIND(str1);
1043610432
kind2 = PyUnicode_KIND(str2);
1043710433
data1 = PyUnicode_DATA(str1);
@@ -10555,6 +10551,11 @@ PyUnicode_Compare(PyObject *left, PyObject *right)
1055510551
if (PyUnicode_READY(left) == -1 ||
1055610552
PyUnicode_READY(right) == -1)
1055710553
return -1;
10554+
10555+
/* a string is equal to itself */
10556+
if (left == right)
10557+
return 0;
10558+
1055810559
return unicode_compare(left, right);
1055910560
}
1056010561
PyErr_Format(PyExc_TypeError,

0 commit comments

Comments
 (0)