/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 | 260M | { |
9 | 260M | Py_ssize_t len = PyUnicode_GET_LENGTH(str1); |
10 | 260M | if (PyUnicode_GET_LENGTH(str2) != len) { |
11 | 70.5M | return 0; |
12 | 70.5M | } |
13 | | |
14 | 190M | int kind = PyUnicode_KIND(str1); |
15 | 190M | if (PyUnicode_KIND(str2) != kind) { |
16 | 8.48M | return 0; |
17 | 8.48M | } |
18 | | |
19 | 181M | const void *data1 = PyUnicode_DATA(str1); |
20 | 181M | const void *data2 = PyUnicode_DATA(str2); |
21 | 181M | return (memcmp(data1, data2, len * kind) == 0); |
22 | 190M | } Line | Count | Source | 8 | 39.3M | { | 9 | 39.3M | Py_ssize_t len = PyUnicode_GET_LENGTH(str1); | 10 | 39.3M | if (PyUnicode_GET_LENGTH(str2) != len) { | 11 | 11.9k | return 0; | 12 | 11.9k | } | 13 | | | 14 | 39.3M | int kind = PyUnicode_KIND(str1); | 15 | 39.3M | if (PyUnicode_KIND(str2) != kind) { | 16 | 0 | return 0; | 17 | 0 | } | 18 | | | 19 | 39.3M | const void *data1 = PyUnicode_DATA(str1); | 20 | 39.3M | const void *data2 = PyUnicode_DATA(str2); | 21 | 39.3M | return (memcmp(data1, data2, len * kind) == 0); | 22 | 39.3M | } |
Line | Count | Source | 8 | 324k | { | 9 | 324k | Py_ssize_t len = PyUnicode_GET_LENGTH(str1); | 10 | 324k | if (PyUnicode_GET_LENGTH(str2) != len) { | 11 | 3 | return 0; | 12 | 3 | } | 13 | | | 14 | 324k | int kind = PyUnicode_KIND(str1); | 15 | 324k | if (PyUnicode_KIND(str2) != kind) { | 16 | 0 | return 0; | 17 | 0 | } | 18 | | | 19 | 324k | const void *data1 = PyUnicode_DATA(str1); | 20 | 324k | const void *data2 = PyUnicode_DATA(str2); | 21 | 324k | return (memcmp(data1, data2, len * kind) == 0); | 22 | 324k | } |
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 | 70.5M | return 0; | 12 | 70.5M | } | 13 | | | 14 | 150M | int kind = PyUnicode_KIND(str1); | 15 | 150M | if (PyUnicode_KIND(str2) != kind) { | 16 | 8.48M | return 0; | 17 | 8.48M | } | 18 | | | 19 | 141M | const void *data1 = PyUnicode_DATA(str1); | 20 | 141M | const void *data2 = PyUnicode_DATA(str2); | 21 | 141M | return (memcmp(data1, data2, len * kind) == 0); | 22 | 150M | } |
|