Mercurial > cpython-lru_cache-weakref
annotate Objects/stringlib/eq.h @ 47426:4dedef4c0dfd
Blocked revisions 63863 via svnmerge
........
r63863 | benjamin.peterson | 2008-06-01 14:01:25 -0500 (Sun, 01 Jun 2008) | 2 lines
add a warning about bgen being removed
........
| author | Benjamin Peterson <benjamin@python.org> |
|---|---|
| date | Sun, 01 Jun 2008 19:04:01 +0000 |
| parents | 444da08f78a4 |
| children | cab14be0ada1 |
| 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 } |
