Coverage Report

Created: 2026-10-31 06:21

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/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
636M
{
9
636M
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
636M
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
107M
        return 0;
12
107M
    }
13
14
528M
    int kind = PyUnicode_KIND(str1);
15
528M
    if (PyUnicode_KIND(str2) != kind) {
16
53.6M
        return 0;
17
53.6M
    }
18
19
475M
    const void *data1 = PyUnicode_DATA(str1);
20
475M
    const void *data2 = PyUnicode_DATA(str2);
21
475M
    return (memcmp(data1, data2, len * kind) == 0);
22
528M
}
dictobject.c:unicode_eq
Line
Count
Source
8
60.2M
{
9
60.2M
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
60.2M
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
29.2k
        return 0;
12
29.2k
    }
13
14
60.1M
    int kind = PyUnicode_KIND(str1);
15
60.1M
    if (PyUnicode_KIND(str2) != kind) {
16
0
        return 0;
17
0
    }
18
19
60.1M
    const void *data1 = PyUnicode_DATA(str1);
20
60.1M
    const void *data2 = PyUnicode_DATA(str2);
21
60.1M
    return (memcmp(data1, data2, len * kind) == 0);
22
60.1M
}
setobject.c:unicode_eq
Line
Count
Source
8
453k
{
9
453k
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
453k
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
13
        return 0;
12
13
    }
13
14
453k
    int kind = PyUnicode_KIND(str1);
15
453k
    if (PyUnicode_KIND(str2) != kind) {
16
0
        return 0;
17
0
    }
18
19
453k
    const void *data1 = PyUnicode_DATA(str1);
20
453k
    const void *data2 = PyUnicode_DATA(str2);
21
453k
    return (memcmp(data1, data2, len * kind) == 0);
22
453k
}
unicodeobject.c:unicode_eq
Line
Count
Source
8
575M
{
9
575M
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
575M
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
107M
        return 0;
12
107M
    }
13
14
468M
    int kind = PyUnicode_KIND(str1);
15
468M
    if (PyUnicode_KIND(str2) != kind) {
16
53.6M
        return 0;
17
53.6M
    }
18
19
414M
    const void *data1 = PyUnicode_DATA(str1);
20
414M
    const void *data2 = PyUnicode_DATA(str2);
21
414M
    return (memcmp(data1, data2, len * kind) == 0);
22
468M
}