File tree 1 file changed +12
-7
lines changed
1 file changed +12
-7
lines changed Original file line number Diff line number Diff line change 4
4
* unicode_eq() is called when the hash of two unicode objects is equal.
5
5
*/
6
6
Py_LOCAL_INLINE (int )
7
- unicode_eq (PyObject * a , PyObject * b )
7
+ unicode_eq (PyObject * str1 , PyObject * str2 )
8
8
{
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 ) {
10
11
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 ) {
14
16
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 );
17
22
}
You can’t perform that action at this time.
0 commit comments