/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 | 676M | { |
9 | 676M | Py_ssize_t len = PyUnicode_GET_LENGTH(str1); |
10 | 676M | if (PyUnicode_GET_LENGTH(str2) != len) { |
11 | 115M | return 0; |
12 | 115M | } |
13 | | |
14 | 561M | int kind = PyUnicode_KIND(str1); |
15 | 561M | if (PyUnicode_KIND(str2) != kind) { |
16 | 50.4M | return 0; |
17 | 50.4M | } |
18 | | |
19 | 510M | const void *data1 = PyUnicode_DATA(str1); |
20 | 510M | const void *data2 = PyUnicode_DATA(str2); |
21 | 510M | return (memcmp(data1, data2, len * kind) == 0); |
22 | 561M | } Line | Count | Source | 8 | 76.0M | { | 9 | 76.0M | Py_ssize_t len = PyUnicode_GET_LENGTH(str1); | 10 | 76.0M | if (PyUnicode_GET_LENGTH(str2) != len) { | 11 | 17.1k | return 0; | 12 | 17.1k | } | 13 | | | 14 | 75.9M | int kind = PyUnicode_KIND(str1); | 15 | 75.9M | if (PyUnicode_KIND(str2) != kind) { | 16 | 0 | return 0; | 17 | 0 | } | 18 | | | 19 | 75.9M | const void *data1 = PyUnicode_DATA(str1); | 20 | 75.9M | const void *data2 = PyUnicode_DATA(str2); | 21 | 75.9M | return (memcmp(data1, data2, len * kind) == 0); | 22 | 75.9M | } |
Line | Count | Source | 8 | 432k | { | 9 | 432k | Py_ssize_t len = PyUnicode_GET_LENGTH(str1); | 10 | 432k | if (PyUnicode_GET_LENGTH(str2) != len) { | 11 | 19 | return 0; | 12 | 19 | } | 13 | | | 14 | 432k | int kind = PyUnicode_KIND(str1); | 15 | 432k | if (PyUnicode_KIND(str2) != kind) { | 16 | 0 | return 0; | 17 | 0 | } | 18 | | | 19 | 432k | const void *data1 = PyUnicode_DATA(str1); | 20 | 432k | const void *data2 = PyUnicode_DATA(str2); | 21 | 432k | return (memcmp(data1, data2, len * kind) == 0); | 22 | 432k | } |
unicodeobject.c:unicode_eq Line | Count | Source | 8 | 600M | { | 9 | 600M | Py_ssize_t len = PyUnicode_GET_LENGTH(str1); | 10 | 600M | if (PyUnicode_GET_LENGTH(str2) != len) { | 11 | 115M | return 0; | 12 | 115M | } | 13 | | | 14 | 485M | int kind = PyUnicode_KIND(str1); | 15 | 485M | if (PyUnicode_KIND(str2) != kind) { | 16 | 50.4M | return 0; | 17 | 50.4M | } | 18 | | | 19 | 434M | const void *data1 = PyUnicode_DATA(str1); | 20 | 434M | const void *data2 = PyUnicode_DATA(str2); | 21 | 434M | return (memcmp(data1, data2, len * kind) == 0); | 22 | 485M | } |
|