annotate Objects/stringlib/eq.h @ 48715:48dddfd2fbf3

RPC_WSTR is not available Visual Studio 2003 or earlier. (Maybe I should have defined RPC_WSTR on old compiler, but uuidcreate() is only place using it, so I simply replaced with unsigned short *)
author Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
date Sun, 17 Aug 2008 07:26:26 +0000
parents 444da08f78a4
children cab14be0ada1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
44252
444da08f78a4 Fixed issue #1564: The set implementation should special-case PyUnicode instead of PyString
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
1 /* Fast unicode equal function optimized for dictobject.c and setobject.c */
444da08f78a4 Fixed issue #1564: The set implementation should special-case PyUnicode instead of PyString
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
2
444da08f78a4 Fixed issue #1564: The set implementation should special-case PyUnicode instead of PyString
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
3 /* Return 1 if two unicode objects are equal, 0 if not.
444da08f78a4 Fixed issue #1564: The set implementation should special-case PyUnicode instead of PyString
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
4 * unicode_eq() is called when the hash of two unicode objects is equal.
444da08f78a4 Fixed issue #1564: The set implementation should special-case PyUnicode instead of PyString
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
5 */
444da08f78a4 Fixed issue #1564: The set implementation should special-case PyUnicode instead of PyString
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
6 Py_LOCAL_INLINE(int)
444da08f78a4 Fixed issue #1564: The set implementation should special-case PyUnicode instead of PyString
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
7 unicode_eq(PyObject *aa, PyObject *bb)
444da08f78a4 Fixed issue #1564: The set implementation should special-case PyUnicode instead of PyString
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
8 {
444da08f78a4 Fixed issue #1564: The set implementation should special-case PyUnicode instead of PyString
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
9 register PyUnicodeObject *a = (PyUnicodeObject *)aa;
444da08f78a4 Fixed issue #1564: The set implementation should special-case PyUnicode instead of PyString
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
10 register PyUnicodeObject *b = (PyUnicodeObject *)bb;
444da08f78a4 Fixed issue #1564: The set implementation should special-case PyUnicode instead of PyString
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
11
444da08f78a4 Fixed issue #1564: The set implementation should special-case PyUnicode instead of PyString
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
12 if (a->length != b->length)
444da08f78a4 Fixed issue #1564: The set implementation should special-case PyUnicode instead of PyString
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
13 return 0;
444da08f78a4 Fixed issue #1564: The set implementation should special-case PyUnicode instead of PyString
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
14 if (a->length == 0)
444da08f78a4 Fixed issue #1564: The set implementation should special-case PyUnicode instead of PyString
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
15 return 1;
444da08f78a4 Fixed issue #1564: The set implementation should special-case PyUnicode instead of PyString
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
16 if (a->str[0] != b->str[0])
444da08f78a4 Fixed issue #1564: The set implementation should special-case PyUnicode instead of PyString
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
17 return 0;
444da08f78a4 Fixed issue #1564: The set implementation should special-case PyUnicode instead of PyString
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
18 if (a->length == 1)
444da08f78a4 Fixed issue #1564: The set implementation should special-case PyUnicode instead of PyString
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
19 return 1;
444da08f78a4 Fixed issue #1564: The set implementation should special-case PyUnicode instead of PyString
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
20 return memcmp(a->str, b->str, a->length * sizeof(Py_UNICODE)) == 0;
444da08f78a4 Fixed issue #1564: The set implementation should special-case PyUnicode instead of PyString
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
21 }