1 /* Fast unicode equal function optimized for dictobject.c and setobject.c */ 2 3 /* Return 1 if two unicode objects are equal, 0 if not. 4 * unicode_eq() is called when the hash of two unicode objects is equal. 5 */ 6 Py_LOCAL_INLINE(int) unicode_eq(PyObject * a,PyObject * b)7unicode_eq(PyObject *a, PyObject *b) 8 { 9 if (PyUnicode_GET_LENGTH(a) != PyUnicode_GET_LENGTH(b)) 10 return 0; 11 if (PyUnicode_GET_LENGTH(a) == 0) 12 return 1; 13 if (PyUnicode_KIND(a) != PyUnicode_KIND(b)) 14 return 0; 15 return memcmp(PyUnicode_1BYTE_DATA(a), PyUnicode_1BYTE_DATA(b), 16 PyUnicode_GET_LENGTH(a) * PyUnicode_KIND(a)) == 0; 17 } 18