/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 | 262M | { |
9 | 262M | Py_ssize_t len = PyUnicode_GET_LENGTH(str1); |
10 | 262M | if (PyUnicode_GET_LENGTH(str2) != len) { |
11 | 63.5M | return 0; |
12 | 63.5M | } |
13 | | |
14 | 199M | int kind = PyUnicode_KIND(str1); |
15 | 199M | if (PyUnicode_KIND(str2) != kind) { |
16 | 20.2M | return 0; |
17 | 20.2M | } |
18 | | |
19 | 179M | const void *data1 = PyUnicode_DATA(str1); |
20 | 179M | const void *data2 = PyUnicode_DATA(str2); |
21 | 179M | return (memcmp(data1, data2, len * kind) == 0); |
22 | 199M | } Line | Count | Source | 8 | 42.1M | { | 9 | 42.1M | Py_ssize_t len = PyUnicode_GET_LENGTH(str1); | 10 | 42.1M | if (PyUnicode_GET_LENGTH(str2) != len) { | 11 | 13.2k | return 0; | 12 | 13.2k | } | 13 | | | 14 | 42.1M | int kind = PyUnicode_KIND(str1); | 15 | 42.1M | if (PyUnicode_KIND(str2) != kind) { | 16 | 0 | return 0; | 17 | 0 | } | 18 | | | 19 | 42.1M | const void *data1 = PyUnicode_DATA(str1); | 20 | 42.1M | const void *data2 = PyUnicode_DATA(str2); | 21 | 42.1M | return (memcmp(data1, data2, len * kind) == 0); | 22 | 42.1M | } |
Line | Count | Source | 8 | 323k | { | 9 | 323k | Py_ssize_t len = PyUnicode_GET_LENGTH(str1); | 10 | 323k | if (PyUnicode_GET_LENGTH(str2) != len) { | 11 | 6 | return 0; | 12 | 6 | } | 13 | | | 14 | 323k | int kind = PyUnicode_KIND(str1); | 15 | 323k | if (PyUnicode_KIND(str2) != kind) { | 16 | 0 | return 0; | 17 | 0 | } | 18 | | | 19 | 323k | const void *data1 = PyUnicode_DATA(str1); | 20 | 323k | const void *data2 = PyUnicode_DATA(str2); | 21 | 323k | return (memcmp(data1, data2, len * kind) == 0); | 22 | 323k | } |
unicodeobject.c:unicode_eq Line | Count | Source | 8 | 220M | { | 9 | 220M | Py_ssize_t len = PyUnicode_GET_LENGTH(str1); | 10 | 220M | if (PyUnicode_GET_LENGTH(str2) != len) { | 11 | 63.5M | return 0; | 12 | 63.5M | } | 13 | | | 14 | 156M | int kind = PyUnicode_KIND(str1); | 15 | 156M | if (PyUnicode_KIND(str2) != kind) { | 16 | 20.2M | return 0; | 17 | 20.2M | } | 18 | | | 19 | 136M | const void *data1 = PyUnicode_DATA(str1); | 20 | 136M | const void *data2 = PyUnicode_DATA(str2); | 21 | 136M | return (memcmp(data1, data2, len * kind) == 0); | 22 | 156M | } |
|