/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 | 649M | { |
9 | 649M | Py_ssize_t len = PyUnicode_GET_LENGTH(str1); |
10 | 649M | if (PyUnicode_GET_LENGTH(str2) != len) { |
11 | 120M | return 0; |
12 | 120M | } |
13 | | |
14 | 529M | int kind = PyUnicode_KIND(str1); |
15 | 529M | if (PyUnicode_KIND(str2) != kind) { |
16 | 30.7M | return 0; |
17 | 30.7M | } |
18 | | |
19 | 499M | const void *data1 = PyUnicode_DATA(str1); |
20 | 499M | const void *data2 = PyUnicode_DATA(str2); |
21 | 499M | return (memcmp(data1, data2, len * kind) == 0); |
22 | 529M | } Line | Count | Source | 8 | 66.5M | { | 9 | 66.5M | Py_ssize_t len = PyUnicode_GET_LENGTH(str1); | 10 | 66.5M | if (PyUnicode_GET_LENGTH(str2) != len) { | 11 | 22.8k | return 0; | 12 | 22.8k | } | 13 | | | 14 | 66.5M | int kind = PyUnicode_KIND(str1); | 15 | 66.5M | if (PyUnicode_KIND(str2) != kind) { | 16 | 0 | return 0; | 17 | 0 | } | 18 | | | 19 | 66.5M | const void *data1 = PyUnicode_DATA(str1); | 20 | 66.5M | const void *data2 = PyUnicode_DATA(str2); | 21 | 66.5M | return (memcmp(data1, data2, len * kind) == 0); | 22 | 66.5M | } |
Line | Count | Source | 8 | 405k | { | 9 | 405k | Py_ssize_t len = PyUnicode_GET_LENGTH(str1); | 10 | 405k | if (PyUnicode_GET_LENGTH(str2) != len) { | 11 | 9 | return 0; | 12 | 9 | } | 13 | | | 14 | 405k | int kind = PyUnicode_KIND(str1); | 15 | 405k | if (PyUnicode_KIND(str2) != kind) { | 16 | 0 | return 0; | 17 | 0 | } | 18 | | | 19 | 405k | const void *data1 = PyUnicode_DATA(str1); | 20 | 405k | const void *data2 = PyUnicode_DATA(str2); | 21 | 405k | return (memcmp(data1, data2, len * kind) == 0); | 22 | 405k | } |
unicodeobject.c:unicode_eq Line | Count | Source | 8 | 582M | { | 9 | 582M | Py_ssize_t len = PyUnicode_GET_LENGTH(str1); | 10 | 582M | if (PyUnicode_GET_LENGTH(str2) != len) { | 11 | 120M | return 0; | 12 | 120M | } | 13 | | | 14 | 462M | int kind = PyUnicode_KIND(str1); | 15 | 462M | if (PyUnicode_KIND(str2) != kind) { | 16 | 30.7M | return 0; | 17 | 30.7M | } | 18 | | | 19 | 432M | const void *data1 = PyUnicode_DATA(str1); | 20 | 432M | const void *data2 = PyUnicode_DATA(str2); | 21 | 432M | return (memcmp(data1, data2, len * kind) == 0); | 22 | 462M | } |
|