Coverage Report

Created: 2026-01-10 06:41

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
585M
{
9
585M
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
585M
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
90.8M
        return 0;
12
90.8M
    }
13
14
494M
    int kind = PyUnicode_KIND(str1);
15
494M
    if (PyUnicode_KIND(str2) != kind) {
16
35.8M
        return 0;
17
35.8M
    }
18
19
458M
    const void *data1 = PyUnicode_DATA(str1);
20
458M
    const void *data2 = PyUnicode_DATA(str2);
21
458M
    return (memcmp(data1, data2, len * kind) == 0);
22
494M
}
dictobject.c:unicode_eq
Line
Count
Source
8
73.7M
{
9
73.7M
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
73.7M
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
17.1k
        return 0;
12
17.1k
    }
13
14
73.7M
    int kind = PyUnicode_KIND(str1);
15
73.7M
    if (PyUnicode_KIND(str2) != kind) {
16
0
        return 0;
17
0
    }
18
19
73.7M
    const void *data1 = PyUnicode_DATA(str1);
20
73.7M
    const void *data2 = PyUnicode_DATA(str2);
21
73.7M
    return (memcmp(data1, data2, len * kind) == 0);
22
73.7M
}
setobject.c:unicode_eq
Line
Count
Source
8
494k
{
9
494k
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
494k
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
6
        return 0;
12
6
    }
13
14
494k
    int kind = PyUnicode_KIND(str1);
15
494k
    if (PyUnicode_KIND(str2) != kind) {
16
0
        return 0;
17
0
    }
18
19
494k
    const void *data1 = PyUnicode_DATA(str1);
20
494k
    const void *data2 = PyUnicode_DATA(str2);
21
494k
    return (memcmp(data1, data2, len * kind) == 0);
22
494k
}
unicodeobject.c:unicode_eq
Line
Count
Source
8
511M
{
9
511M
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
511M
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
90.8M
        return 0;
12
90.8M
    }
13
14
420M
    int kind = PyUnicode_KIND(str1);
15
420M
    if (PyUnicode_KIND(str2) != kind) {
16
35.8M
        return 0;
17
35.8M
    }
18
19
384M
    const void *data1 = PyUnicode_DATA(str1);
20
384M
    const void *data2 = PyUnicode_DATA(str2);
21
384M
    return (memcmp(data1, data2, len * kind) == 0);
22
420M
}