blob: 4e989dce6d4a300381be238a08baabdfcec5058a [file] [log] [blame]
Christian Heimes0ded5b52007-12-10 15:50:56 +00001/* 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 */
6Py_LOCAL_INLINE(int)
7unicode_eq(PyObject *aa, PyObject *bb)
8{
9 register PyUnicodeObject *a = (PyUnicodeObject *)aa;
10 register PyUnicodeObject *b = (PyUnicodeObject *)bb;
11
12 if (a->length != b->length)
13 return 0;
14 if (a->length == 0)
15 return 1;
16 if (a->str[0] != b->str[0])
17 return 0;
18 if (a->length == 1)
19 return 1;
20 return memcmp(a->str, b->str, a->length * sizeof(Py_UNICODE)) == 0;
21}