/src/cpython/Objects/stringlib/eq.h
Line | Count | Source |
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) |
7 | | unicode_eq(PyObject *str1, PyObject *str2) |
8 | 638M | { |
9 | 638M | Py_ssize_t len = PyUnicode_GET_LENGTH(str1); |
10 | 638M | if (PyUnicode_GET_LENGTH(str2) != len) { |
11 | 91.5M | return 0; |
12 | 91.5M | } |
13 | | |
14 | 546M | int kind = PyUnicode_KIND(str1); |
15 | 546M | if (PyUnicode_KIND(str2) != kind) { |
16 | 41.0M | return 0; |
17 | 41.0M | } |
18 | | |
19 | 505M | const void *data1 = PyUnicode_DATA(str1); |
20 | 505M | const void *data2 = PyUnicode_DATA(str2); |
21 | 505M | return (memcmp(data1, data2, len * kind) == 0); |
22 | 546M | } Line | Count | Source | 8 | 79.0M | { | 9 | 79.0M | Py_ssize_t len = PyUnicode_GET_LENGTH(str1); | 10 | 79.0M | if (PyUnicode_GET_LENGTH(str2) != len) { | 11 | 7.56k | return 0; | 12 | 7.56k | } | 13 | | | 14 | 79.0M | int kind = PyUnicode_KIND(str1); | 15 | 79.0M | if (PyUnicode_KIND(str2) != kind) { | 16 | 0 | return 0; | 17 | 0 | } | 18 | | | 19 | 79.0M | const void *data1 = PyUnicode_DATA(str1); | 20 | 79.0M | const void *data2 = PyUnicode_DATA(str2); | 21 | 79.0M | return (memcmp(data1, data2, len * kind) == 0); | 22 | 79.0M | } |
Line | Count | Source | 8 | 532k | { | 9 | 532k | Py_ssize_t len = PyUnicode_GET_LENGTH(str1); | 10 | 532k | if (PyUnicode_GET_LENGTH(str2) != len) { | 11 | 8 | return 0; | 12 | 8 | } | 13 | | | 14 | 532k | int kind = PyUnicode_KIND(str1); | 15 | 532k | if (PyUnicode_KIND(str2) != kind) { | 16 | 0 | return 0; | 17 | 0 | } | 18 | | | 19 | 532k | const void *data1 = PyUnicode_DATA(str1); | 20 | 532k | const void *data2 = PyUnicode_DATA(str2); | 21 | 532k | return (memcmp(data1, data2, len * kind) == 0); | 22 | 532k | } |
unicodeobject.c:unicode_eq Line | Count | Source | 8 | 558M | { | 9 | 558M | Py_ssize_t len = PyUnicode_GET_LENGTH(str1); | 10 | 558M | if (PyUnicode_GET_LENGTH(str2) != len) { | 11 | 91.5M | return 0; | 12 | 91.5M | } | 13 | | | 14 | 466M | int kind = PyUnicode_KIND(str1); | 15 | 466M | if (PyUnicode_KIND(str2) != kind) { | 16 | 41.0M | return 0; | 17 | 41.0M | } | 18 | | | 19 | 425M | const void *data1 = PyUnicode_DATA(str1); | 20 | 425M | const void *data2 = PyUnicode_DATA(str2); | 21 | 425M | return (memcmp(data1, data2, len * kind) == 0); | 22 | 466M | } |
|