/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 | 631M | { |
9 | 631M | Py_ssize_t len = PyUnicode_GET_LENGTH(str1); |
10 | 631M | if (PyUnicode_GET_LENGTH(str2) != len) { |
11 | 96.7M | return 0; |
12 | 96.7M | } |
13 | | |
14 | 534M | int kind = PyUnicode_KIND(str1); |
15 | 534M | if (PyUnicode_KIND(str2) != kind) { |
16 | 33.1M | return 0; |
17 | 33.1M | } |
18 | | |
19 | 501M | const void *data1 = PyUnicode_DATA(str1); |
20 | 501M | const void *data2 = PyUnicode_DATA(str2); |
21 | 501M | return (memcmp(data1, data2, len * kind) == 0); |
22 | 534M | } Line | Count | Source | 8 | 82.0M | { | 9 | 82.0M | Py_ssize_t len = PyUnicode_GET_LENGTH(str1); | 10 | 82.0M | if (PyUnicode_GET_LENGTH(str2) != len) { | 11 | 20.2k | return 0; | 12 | 20.2k | } | 13 | | | 14 | 82.0M | int kind = PyUnicode_KIND(str1); | 15 | 82.0M | if (PyUnicode_KIND(str2) != kind) { | 16 | 0 | return 0; | 17 | 0 | } | 18 | | | 19 | 82.0M | const void *data1 = PyUnicode_DATA(str1); | 20 | 82.0M | const void *data2 = PyUnicode_DATA(str2); | 21 | 82.0M | return (memcmp(data1, data2, len * kind) == 0); | 22 | 82.0M | } |
Line | Count | Source | 8 | 440k | { | 9 | 440k | Py_ssize_t len = PyUnicode_GET_LENGTH(str1); | 10 | 440k | if (PyUnicode_GET_LENGTH(str2) != len) { | 11 | 3 | return 0; | 12 | 3 | } | 13 | | | 14 | 440k | int kind = PyUnicode_KIND(str1); | 15 | 440k | if (PyUnicode_KIND(str2) != kind) { | 16 | 0 | return 0; | 17 | 0 | } | 18 | | | 19 | 440k | const void *data1 = PyUnicode_DATA(str1); | 20 | 440k | const void *data2 = PyUnicode_DATA(str2); | 21 | 440k | return (memcmp(data1, data2, len * kind) == 0); | 22 | 440k | } |
unicodeobject.c:unicode_eq Line | Count | Source | 8 | 548M | { | 9 | 548M | Py_ssize_t len = PyUnicode_GET_LENGTH(str1); | 10 | 548M | if (PyUnicode_GET_LENGTH(str2) != len) { | 11 | 96.7M | return 0; | 12 | 96.7M | } | 13 | | | 14 | 452M | int kind = PyUnicode_KIND(str1); | 15 | 452M | if (PyUnicode_KIND(str2) != kind) { | 16 | 33.1M | return 0; | 17 | 33.1M | } | 18 | | | 19 | 418M | const void *data1 = PyUnicode_DATA(str1); | 20 | 418M | const void *data2 = PyUnicode_DATA(str2); | 21 | 418M | return (memcmp(data1, data2, len * kind) == 0); | 22 | 452M | } |
|