Coverage Report

Created: 2026-06-21 06:15

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
611M
{
9
611M
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
611M
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
129M
        return 0;
12
129M
    }
13
14
482M
    int kind = PyUnicode_KIND(str1);
15
482M
    if (PyUnicode_KIND(str2) != kind) {
16
34.8M
        return 0;
17
34.8M
    }
18
19
448M
    const void *data1 = PyUnicode_DATA(str1);
20
448M
    const void *data2 = PyUnicode_DATA(str2);
21
448M
    return (memcmp(data1, data2, len * kind) == 0);
22
482M
}
dictobject.c:unicode_eq
Line
Count
Source
8
42.3M
{
9
42.3M
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
42.3M
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
22.7k
        return 0;
12
22.7k
    }
13
14
42.3M
    int kind = PyUnicode_KIND(str1);
15
42.3M
    if (PyUnicode_KIND(str2) != kind) {
16
0
        return 0;
17
0
    }
18
19
42.3M
    const void *data1 = PyUnicode_DATA(str1);
20
42.3M
    const void *data2 = PyUnicode_DATA(str2);
21
42.3M
    return (memcmp(data1, data2, len * kind) == 0);
22
42.3M
}
setobject.c:unicode_eq
Line
Count
Source
8
206k
{
9
206k
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
206k
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
12
        return 0;
12
12
    }
13
14
206k
    int kind = PyUnicode_KIND(str1);
15
206k
    if (PyUnicode_KIND(str2) != kind) {
16
0
        return 0;
17
0
    }
18
19
206k
    const void *data1 = PyUnicode_DATA(str1);
20
206k
    const void *data2 = PyUnicode_DATA(str2);
21
206k
    return (memcmp(data1, data2, len * kind) == 0);
22
206k
}
unicodeobject.c:unicode_eq
Line
Count
Source
8
569M
{
9
569M
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
569M
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
128M
        return 0;
12
128M
    }
13
14
440M
    int kind = PyUnicode_KIND(str1);
15
440M
    if (PyUnicode_KIND(str2) != kind) {
16
34.8M
        return 0;
17
34.8M
    }
18
19
405M
    const void *data1 = PyUnicode_DATA(str1);
20
405M
    const void *data2 = PyUnicode_DATA(str2);
21
405M
    return (memcmp(data1, data2, len * kind) == 0);
22
440M
}