/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 | 648M | { |
9 | 648M | Py_ssize_t len = PyUnicode_GET_LENGTH(str1); |
10 | 648M | if (PyUnicode_GET_LENGTH(str2) != len) { |
11 | 123M | return 0; |
12 | 123M | } |
13 | | |
14 | 524M | int kind = PyUnicode_KIND(str1); |
15 | 524M | if (PyUnicode_KIND(str2) != kind) { |
16 | 33.0M | return 0; |
17 | 33.0M | } |
18 | | |
19 | 491M | const void *data1 = PyUnicode_DATA(str1); |
20 | 491M | const void *data2 = PyUnicode_DATA(str2); |
21 | 491M | return (memcmp(data1, data2, len * kind) == 0); |
22 | 524M | } Line | Count | Source | 8 | 83.7M | { | 9 | 83.7M | Py_ssize_t len = PyUnicode_GET_LENGTH(str1); | 10 | 83.7M | if (PyUnicode_GET_LENGTH(str2) != len) { | 11 | 17.8k | return 0; | 12 | 17.8k | } | 13 | | | 14 | 83.7M | int kind = PyUnicode_KIND(str1); | 15 | 83.7M | if (PyUnicode_KIND(str2) != kind) { | 16 | 0 | return 0; | 17 | 0 | } | 18 | | | 19 | 83.7M | const void *data1 = PyUnicode_DATA(str1); | 20 | 83.7M | const void *data2 = PyUnicode_DATA(str2); | 21 | 83.7M | return (memcmp(data1, data2, len * kind) == 0); | 22 | 83.7M | } |
Line | Count | Source | 8 | 446k | { | 9 | 446k | Py_ssize_t len = PyUnicode_GET_LENGTH(str1); | 10 | 446k | if (PyUnicode_GET_LENGTH(str2) != len) { | 11 | 3 | return 0; | 12 | 3 | } | 13 | | | 14 | 446k | int kind = PyUnicode_KIND(str1); | 15 | 446k | if (PyUnicode_KIND(str2) != kind) { | 16 | 0 | return 0; | 17 | 0 | } | 18 | | | 19 | 446k | const void *data1 = PyUnicode_DATA(str1); | 20 | 446k | const void *data2 = PyUnicode_DATA(str2); | 21 | 446k | return (memcmp(data1, data2, len * kind) == 0); | 22 | 446k | } |
unicodeobject.c:unicode_eq Line | Count | Source | 8 | 564M | { | 9 | 564M | Py_ssize_t len = PyUnicode_GET_LENGTH(str1); | 10 | 564M | if (PyUnicode_GET_LENGTH(str2) != len) { | 11 | 123M | return 0; | 12 | 123M | } | 13 | | | 14 | 440M | int kind = PyUnicode_KIND(str1); | 15 | 440M | if (PyUnicode_KIND(str2) != kind) { | 16 | 33.0M | return 0; | 17 | 33.0M | } | 18 | | | 19 | 407M | const void *data1 = PyUnicode_DATA(str1); | 20 | 407M | const void *data2 = PyUnicode_DATA(str2); | 21 | 407M | return (memcmp(data1, data2, len * kind) == 0); | 22 | 440M | } |
|