Coverage Report

Created: 2025-12-07 07:03

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
628M
{
9
628M
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
628M
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
85.7M
        return 0;
12
85.7M
    }
13
14
543M
    int kind = PyUnicode_KIND(str1);
15
543M
    if (PyUnicode_KIND(str2) != kind) {
16
44.6M
        return 0;
17
44.6M
    }
18
19
498M
    const void *data1 = PyUnicode_DATA(str1);
20
498M
    const void *data2 = PyUnicode_DATA(str2);
21
498M
    return (memcmp(data1, data2, len * kind) == 0);
22
543M
}
dictobject.c:unicode_eq
Line
Count
Source
8
80.8M
{
9
80.8M
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
80.8M
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
7.50k
        return 0;
12
7.50k
    }
13
14
80.8M
    int kind = PyUnicode_KIND(str1);
15
80.8M
    if (PyUnicode_KIND(str2) != kind) {
16
0
        return 0;
17
0
    }
18
19
80.8M
    const void *data1 = PyUnicode_DATA(str1);
20
80.8M
    const void *data2 = PyUnicode_DATA(str2);
21
80.8M
    return (memcmp(data1, data2, len * kind) == 0);
22
80.8M
}
setobject.c:unicode_eq
Line
Count
Source
8
491k
{
9
491k
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
491k
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
3
        return 0;
12
3
    }
13
14
491k
    int kind = PyUnicode_KIND(str1);
15
491k
    if (PyUnicode_KIND(str2) != kind) {
16
0
        return 0;
17
0
    }
18
19
491k
    const void *data1 = PyUnicode_DATA(str1);
20
491k
    const void *data2 = PyUnicode_DATA(str2);
21
491k
    return (memcmp(data1, data2, len * kind) == 0);
22
491k
}
unicodeobject.c:unicode_eq
Line
Count
Source
8
547M
{
9
547M
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
547M
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
85.6M
        return 0;
12
85.6M
    }
13
14
461M
    int kind = PyUnicode_KIND(str1);
15
461M
    if (PyUnicode_KIND(str2) != kind) {
16
44.6M
        return 0;
17
44.6M
    }
18
19
417M
    const void *data1 = PyUnicode_DATA(str1);
20
417M
    const void *data2 = PyUnicode_DATA(str2);
21
417M
    return (memcmp(data1, data2, len * kind) == 0);
22
461M
}