/src/cpython3/Objects/stringlib/eq.h
Line | Count | Source (jump to first uncovered line) |
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 | 70.2M | { |
9 | 70.2M | Py_ssize_t len = PyUnicode_GET_LENGTH(str1); |
10 | 70.2M | if (PyUnicode_GET_LENGTH(str2) != len) { |
11 | 959k | return 0; |
12 | 959k | } |
13 | | |
14 | 69.3M | int kind = PyUnicode_KIND(str1); |
15 | 138M | if (PyUnicode_KIND(str2) != kind) { |
16 | 841k | return 0; |
17 | 841k | } |
18 | | |
19 | 68.4M | const void *data1 = PyUnicode_DATA(str1); |
20 | 68.4M | const void *data2 = PyUnicode_DATA(str2); |
21 | 68.4M | return (memcmp(data1, data2, len * kind) == 0); |
22 | 69.3M | } Line | Count | Source | 8 | 4.22M | { | 9 | 4.22M | Py_ssize_t len = PyUnicode_GET_LENGTH(str1); | 10 | 4.22M | if (PyUnicode_GET_LENGTH(str2) != len) { | 11 | 47.6k | return 0; | 12 | 47.6k | } | 13 | | | 14 | 4.17M | int kind = PyUnicode_KIND(str1); | 15 | 8.35M | if (PyUnicode_KIND(str2) != kind) { | 16 | 0 | return 0; | 17 | 0 | } | 18 | | | 19 | 4.17M | const void *data1 = PyUnicode_DATA(str1); | 20 | 4.17M | const void *data2 = PyUnicode_DATA(str2); | 21 | 4.17M | return (memcmp(data1, data2, len * kind) == 0); | 22 | 4.17M | } |
Line | Count | Source | 8 | 73.7k | { | 9 | 73.7k | Py_ssize_t len = PyUnicode_GET_LENGTH(str1); | 10 | 73.7k | if (PyUnicode_GET_LENGTH(str2) != len) { | 11 | 0 | return 0; | 12 | 0 | } | 13 | | | 14 | 73.7k | int kind = PyUnicode_KIND(str1); | 15 | 147k | if (PyUnicode_KIND(str2) != kind) { | 16 | 0 | return 0; | 17 | 0 | } | 18 | | | 19 | 73.7k | const void *data1 = PyUnicode_DATA(str1); | 20 | 73.7k | const void *data2 = PyUnicode_DATA(str2); | 21 | 73.7k | return (memcmp(data1, data2, len * kind) == 0); | 22 | 73.7k | } |
unicodeobject.c:unicode_eq Line | Count | Source | 8 | 65.9M | { | 9 | 65.9M | Py_ssize_t len = PyUnicode_GET_LENGTH(str1); | 10 | 65.9M | if (PyUnicode_GET_LENGTH(str2) != len) { | 11 | 911k | return 0; | 12 | 911k | } | 13 | | | 14 | 65.0M | int kind = PyUnicode_KIND(str1); | 15 | 130M | if (PyUnicode_KIND(str2) != kind) { | 16 | 841k | return 0; | 17 | 841k | } | 18 | | | 19 | 64.2M | const void *data1 = PyUnicode_DATA(str1); | 20 | 64.2M | const void *data2 = PyUnicode_DATA(str2); | 21 | 64.2M | return (memcmp(data1, data2, len * kind) == 0); | 22 | 65.0M | } |
|