Coverage Report

Created: 2025-11-02 06:30

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
252M
{
9
252M
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
252M
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
71.8M
        return 0;
12
71.8M
    }
13
14
180M
    int kind = PyUnicode_KIND(str1);
15
180M
    if (PyUnicode_KIND(str2) != kind) {
16
8.22M
        return 0;
17
8.22M
    }
18
19
172M
    const void *data1 = PyUnicode_DATA(str1);
20
172M
    const void *data2 = PyUnicode_DATA(str2);
21
172M
    return (memcmp(data1, data2, len * kind) == 0);
22
180M
}
dictobject.c:unicode_eq
Line
Count
Source
8
42.6M
{
9
42.6M
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
42.6M
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
11.3k
        return 0;
12
11.3k
    }
13
14
42.5M
    int kind = PyUnicode_KIND(str1);
15
42.5M
    if (PyUnicode_KIND(str2) != kind) {
16
0
        return 0;
17
0
    }
18
19
42.5M
    const void *data1 = PyUnicode_DATA(str1);
20
42.5M
    const void *data2 = PyUnicode_DATA(str2);
21
42.5M
    return (memcmp(data1, data2, len * kind) == 0);
22
42.5M
}
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
3
        return 0;
12
3
    }
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
209M
{
9
209M
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
209M
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
71.8M
        return 0;
12
71.8M
    }
13
14
137M
    int kind = PyUnicode_KIND(str1);
15
137M
    if (PyUnicode_KIND(str2) != kind) {
16
8.22M
        return 0;
17
8.22M
    }
18
19
129M
    const void *data1 = PyUnicode_DATA(str1);
20
129M
    const void *data2 = PyUnicode_DATA(str2);
21
129M
    return (memcmp(data1, data2, len * kind) == 0);
22
137M
}