Coverage Report

Created: 2026-04-12 06:54

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
625M
{
9
625M
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
625M
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
119M
        return 0;
12
119M
    }
13
14
506M
    int kind = PyUnicode_KIND(str1);
15
506M
    if (PyUnicode_KIND(str2) != kind) {
16
26.3M
        return 0;
17
26.3M
    }
18
19
479M
    const void *data1 = PyUnicode_DATA(str1);
20
479M
    const void *data2 = PyUnicode_DATA(str2);
21
479M
    return (memcmp(data1, data2, len * kind) == 0);
22
506M
}
dictobject.c:unicode_eq
Line
Count
Source
8
64.8M
{
9
64.8M
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
64.8M
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
23.7k
        return 0;
12
23.7k
    }
13
14
64.7M
    int kind = PyUnicode_KIND(str1);
15
64.7M
    if (PyUnicode_KIND(str2) != kind) {
16
0
        return 0;
17
0
    }
18
19
64.7M
    const void *data1 = PyUnicode_DATA(str1);
20
64.7M
    const void *data2 = PyUnicode_DATA(str2);
21
64.7M
    return (memcmp(data1, data2, len * kind) == 0);
22
64.7M
}
setobject.c:unicode_eq
Line
Count
Source
8
276k
{
9
276k
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
276k
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
25
        return 0;
12
25
    }
13
14
276k
    int kind = PyUnicode_KIND(str1);
15
276k
    if (PyUnicode_KIND(str2) != kind) {
16
0
        return 0;
17
0
    }
18
19
276k
    const void *data1 = PyUnicode_DATA(str1);
20
276k
    const void *data2 = PyUnicode_DATA(str2);
21
276k
    return (memcmp(data1, data2, len * kind) == 0);
22
276k
}
unicodeobject.c:unicode_eq
Line
Count
Source
8
560M
{
9
560M
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
560M
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
119M
        return 0;
12
119M
    }
13
14
441M
    int kind = PyUnicode_KIND(str1);
15
441M
    if (PyUnicode_KIND(str2) != kind) {
16
26.3M
        return 0;
17
26.3M
    }
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
441M
}