/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 | 67.2M | { |
9 | 67.2M | Py_ssize_t len = PyUnicode_GET_LENGTH(str1); |
10 | 67.2M | if (PyUnicode_GET_LENGTH(str2) != len) { |
11 | 850k | return 0; |
12 | 850k | } |
13 | | |
14 | 66.4M | int kind = PyUnicode_KIND(str1); |
15 | 132M | if (PyUnicode_KIND(str2) != kind) { |
16 | 919k | return 0; |
17 | 919k | } |
18 | | |
19 | 65.5M | const void *data1 = PyUnicode_DATA(str1); |
20 | 65.5M | const void *data2 = PyUnicode_DATA(str2); |
21 | 65.5M | return (memcmp(data1, data2, len * kind) == 0); |
22 | 66.4M | } Line | Count | Source | 8 | 4.20M | { | 9 | 4.20M | Py_ssize_t len = PyUnicode_GET_LENGTH(str1); | 10 | 4.20M | if (PyUnicode_GET_LENGTH(str2) != len) { | 11 | 59.5k | return 0; | 12 | 59.5k | } | 13 | | | 14 | 4.14M | int kind = PyUnicode_KIND(str1); | 15 | 8.28M | if (PyUnicode_KIND(str2) != kind) { | 16 | 0 | return 0; | 17 | 0 | } | 18 | | | 19 | 4.14M | const void *data1 = PyUnicode_DATA(str1); | 20 | 4.14M | const void *data2 = PyUnicode_DATA(str2); | 21 | 4.14M | return (memcmp(data1, data2, len * kind) == 0); | 22 | 4.14M | } |
Line | Count | Source | 8 | 60.9k | { | 9 | 60.9k | Py_ssize_t len = PyUnicode_GET_LENGTH(str1); | 10 | 60.9k | if (PyUnicode_GET_LENGTH(str2) != len) { | 11 | 0 | return 0; | 12 | 0 | } | 13 | | | 14 | 60.9k | int kind = PyUnicode_KIND(str1); | 15 | 121k | if (PyUnicode_KIND(str2) != kind) { | 16 | 0 | return 0; | 17 | 0 | } | 18 | | | 19 | 60.9k | const void *data1 = PyUnicode_DATA(str1); | 20 | 60.9k | const void *data2 = PyUnicode_DATA(str2); | 21 | 60.9k | return (memcmp(data1, data2, len * kind) == 0); | 22 | 60.9k | } |
unicodeobject.c:unicode_eq Line | Count | Source | 8 | 63.0M | { | 9 | 63.0M | Py_ssize_t len = PyUnicode_GET_LENGTH(str1); | 10 | 63.0M | if (PyUnicode_GET_LENGTH(str2) != len) { | 11 | 790k | return 0; | 12 | 790k | } | 13 | | | 14 | 62.2M | int kind = PyUnicode_KIND(str1); | 15 | 124M | if (PyUnicode_KIND(str2) != kind) { | 16 | 919k | return 0; | 17 | 919k | } | 18 | | | 19 | 61.3M | const void *data1 = PyUnicode_DATA(str1); | 20 | 61.3M | const void *data2 = PyUnicode_DATA(str2); | 21 | 61.3M | return (memcmp(data1, data2, len * kind) == 0); | 22 | 62.2M | } |
|