File tree Expand file tree Collapse file tree 1 file changed +12
-7
lines changed Expand file tree Collapse file tree 1 file changed +12
-7
lines changed Original file line number Diff line number Diff line change 44 * unicode_eq() is called when the hash of two unicode objects is equal.
55 */
66Py_LOCAL_INLINE (int )
7- unicode_eq (PyObject * a , PyObject * b )
7+ unicode_eq (PyObject * str1 , PyObject * str2 )
88{
9- if (PyUnicode_GET_LENGTH (a ) != PyUnicode_GET_LENGTH (b ))
9+ Py_ssize_t len = PyUnicode_GET_LENGTH (str1 );
10+ if (PyUnicode_GET_LENGTH (str2 ) != len ) {
1011 return 0 ;
11- if (PyUnicode_GET_LENGTH (a ) == 0 )
12- return 1 ;
13- if (PyUnicode_KIND (a ) != PyUnicode_KIND (b ))
12+ }
13+
14+ int kind = PyUnicode_KIND (str1 );
15+ if (PyUnicode_KIND (str2 ) != kind ) {
1416 return 0 ;
15- return memcmp (PyUnicode_1BYTE_DATA (a ), PyUnicode_1BYTE_DATA (b ),
16- PyUnicode_GET_LENGTH (a ) * PyUnicode_KIND (a )) == 0 ;
17+ }
18+
19+ const void * data1 = PyUnicode_DATA (str1 );
20+ const void * data2 = PyUnicode_DATA (str2 );
21+ return (memcmp (data1 , data2 , len * kind ) == 0 );
1722}
You can’t perform that action at this time.
0 commit comments