/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 | 276M | { |
9 | 276M | Py_ssize_t len = PyUnicode_GET_LENGTH(str1); |
10 | 276M | if (PyUnicode_GET_LENGTH(str2) != len) { |
11 | 84.7M | return 0; |
12 | 84.7M | } |
13 | | |
14 | 191M | int kind = PyUnicode_KIND(str1); |
15 | 191M | if (PyUnicode_KIND(str2) != kind) { |
16 | 8.43M | return 0; |
17 | 8.43M | } |
18 | | |
19 | 182M | const void *data1 = PyUnicode_DATA(str1); |
20 | 182M | const void *data2 = PyUnicode_DATA(str2); |
21 | 182M | return (memcmp(data1, data2, len * kind) == 0); |
22 | 191M | } Line | Count | Source | 8 | 43.6M | { | 9 | 43.6M | Py_ssize_t len = PyUnicode_GET_LENGTH(str1); | 10 | 43.6M | if (PyUnicode_GET_LENGTH(str2) != len) { | 11 | 9.99k | return 0; | 12 | 9.99k | } | 13 | | | 14 | 43.6M | int kind = PyUnicode_KIND(str1); | 15 | 43.6M | if (PyUnicode_KIND(str2) != kind) { | 16 | 0 | return 0; | 17 | 0 | } | 18 | | | 19 | 43.6M | const void *data1 = PyUnicode_DATA(str1); | 20 | 43.6M | const void *data2 = PyUnicode_DATA(str2); | 21 | 43.6M | return (memcmp(data1, data2, len * kind) == 0); | 22 | 43.6M | } |
Line | Count | Source | 8 | 290k | { | 9 | 290k | Py_ssize_t len = PyUnicode_GET_LENGTH(str1); | 10 | 290k | if (PyUnicode_GET_LENGTH(str2) != len) { | 11 | 6 | return 0; | 12 | 6 | } | 13 | | | 14 | 290k | int kind = PyUnicode_KIND(str1); | 15 | 290k | if (PyUnicode_KIND(str2) != kind) { | 16 | 0 | return 0; | 17 | 0 | } | 18 | | | 19 | 290k | const void *data1 = PyUnicode_DATA(str1); | 20 | 290k | const void *data2 = PyUnicode_DATA(str2); | 21 | 290k | return (memcmp(data1, data2, len * kind) == 0); | 22 | 290k | } |
unicodeobject.c:unicode_eq Line | Count | Source | 8 | 232M | { | 9 | 232M | Py_ssize_t len = PyUnicode_GET_LENGTH(str1); | 10 | 232M | if (PyUnicode_GET_LENGTH(str2) != len) { | 11 | 84.7M | return 0; | 12 | 84.7M | } | 13 | | | 14 | 147M | int kind = PyUnicode_KIND(str1); | 15 | 147M | if (PyUnicode_KIND(str2) != kind) { | 16 | 8.43M | return 0; | 17 | 8.43M | } | 18 | | | 19 | 139M | const void *data1 = PyUnicode_DATA(str1); | 20 | 139M | const void *data2 = PyUnicode_DATA(str2); | 21 | 139M | return (memcmp(data1, data2, len * kind) == 0); | 22 | 147M | } |
|