Coverage Report

Created: 2026-07-14 06:16

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
593M
{
9
593M
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
593M
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
129M
        return 0;
12
129M
    }
13
14
464M
    int kind = PyUnicode_KIND(str1);
15
464M
    if (PyUnicode_KIND(str2) != kind) {
16
31.0M
        return 0;
17
31.0M
    }
18
19
433M
    const void *data1 = PyUnicode_DATA(str1);
20
433M
    const void *data2 = PyUnicode_DATA(str2);
21
433M
    return (memcmp(data1, data2, len * kind) == 0);
22
464M
}
dictobject.c:unicode_eq
Line
Count
Source
8
34.9M
{
9
34.9M
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
34.9M
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
15.2k
        return 0;
12
15.2k
    }
13
14
34.9M
    int kind = PyUnicode_KIND(str1);
15
34.9M
    if (PyUnicode_KIND(str2) != kind) {
16
0
        return 0;
17
0
    }
18
19
34.9M
    const void *data1 = PyUnicode_DATA(str1);
20
34.9M
    const void *data2 = PyUnicode_DATA(str2);
21
34.9M
    return (memcmp(data1, data2, len * kind) == 0);
22
34.9M
}
setobject.c:unicode_eq
Line
Count
Source
8
224k
{
9
224k
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
224k
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
15
        return 0;
12
15
    }
13
14
224k
    int kind = PyUnicode_KIND(str1);
15
224k
    if (PyUnicode_KIND(str2) != kind) {
16
0
        return 0;
17
0
    }
18
19
224k
    const void *data1 = PyUnicode_DATA(str1);
20
224k
    const void *data2 = PyUnicode_DATA(str2);
21
224k
    return (memcmp(data1, data2, len * kind) == 0);
22
224k
}
unicodeobject.c:unicode_eq
Line
Count
Source
8
558M
{
9
558M
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
558M
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
129M
        return 0;
12
129M
    }
13
14
428M
    int kind = PyUnicode_KIND(str1);
15
428M
    if (PyUnicode_KIND(str2) != kind) {
16
31.0M
        return 0;
17
31.0M
    }
18
19
397M
    const void *data1 = PyUnicode_DATA(str1);
20
397M
    const void *data2 = PyUnicode_DATA(str2);
21
397M
    return (memcmp(data1, data2, len * kind) == 0);
22
428M
}