/src/cpython3/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 | 79.2M | { |
9 | 79.2M | Py_ssize_t len = PyUnicode_GET_LENGTH(str1); |
10 | 79.2M | if (PyUnicode_GET_LENGTH(str2) != len) { |
11 | 739k | return 0; |
12 | 739k | } |
13 | | |
14 | 78.5M | int kind = PyUnicode_KIND(str1); |
15 | 157M | if (PyUnicode_KIND(str2) != kind) { |
16 | 131k | return 0; |
17 | 131k | } |
18 | | |
19 | 78.4M | const void *data1 = PyUnicode_DATA(str1); |
20 | 78.4M | const void *data2 = PyUnicode_DATA(str2); |
21 | 78.4M | return (memcmp(data1, data2, len * kind) == 0); |
22 | 78.5M | } Line | Count | Source | 8 | 3.58M | { | 9 | 3.58M | Py_ssize_t len = PyUnicode_GET_LENGTH(str1); | 10 | 3.58M | if (PyUnicode_GET_LENGTH(str2) != len) { | 11 | 6.69k | return 0; | 12 | 6.69k | } | 13 | | | 14 | 3.57M | int kind = PyUnicode_KIND(str1); | 15 | 7.15M | if (PyUnicode_KIND(str2) != kind) { | 16 | 0 | return 0; | 17 | 0 | } | 18 | | | 19 | 3.57M | const void *data1 = PyUnicode_DATA(str1); | 20 | 3.57M | const void *data2 = PyUnicode_DATA(str2); | 21 | 3.57M | return (memcmp(data1, data2, len * kind) == 0); | 22 | 3.57M | } |
Line | Count | Source | 8 | 33.8k | { | 9 | 33.8k | Py_ssize_t len = PyUnicode_GET_LENGTH(str1); | 10 | 33.8k | if (PyUnicode_GET_LENGTH(str2) != len) { | 11 | 2 | return 0; | 12 | 2 | } | 13 | | | 14 | 33.8k | int kind = PyUnicode_KIND(str1); | 15 | 67.7k | if (PyUnicode_KIND(str2) != kind) { | 16 | 0 | return 0; | 17 | 0 | } | 18 | | | 19 | 33.8k | const void *data1 = PyUnicode_DATA(str1); | 20 | 33.8k | const void *data2 = PyUnicode_DATA(str2); | 21 | 33.8k | return (memcmp(data1, data2, len * kind) == 0); | 22 | 33.8k | } |
unicodeobject.c:unicode_eq Line | Count | Source | 8 | 75.6M | { | 9 | 75.6M | Py_ssize_t len = PyUnicode_GET_LENGTH(str1); | 10 | 75.6M | if (PyUnicode_GET_LENGTH(str2) != len) { | 11 | 732k | return 0; | 12 | 732k | } | 13 | | | 14 | 74.9M | int kind = PyUnicode_KIND(str1); | 15 | 149M | if (PyUnicode_KIND(str2) != kind) { | 16 | 131k | return 0; | 17 | 131k | } | 18 | | | 19 | 74.8M | const void *data1 = PyUnicode_DATA(str1); | 20 | 74.8M | const void *data2 = PyUnicode_DATA(str2); | 21 | 74.8M | return (memcmp(data1, data2, len * kind) == 0); | 22 | 74.9M | } |
|