Coverage Report

Created: 2026-10-17 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
620M
{
9
620M
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
620M
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
105M
        return 0;
12
105M
    }
13
14
515M
    int kind = PyUnicode_KIND(str1);
15
515M
    if (PyUnicode_KIND(str2) != kind) {
16
43.4M
        return 0;
17
43.4M
    }
18
19
472M
    const void *data1 = PyUnicode_DATA(str1);
20
472M
    const void *data2 = PyUnicode_DATA(str2);
21
472M
    return (memcmp(data1, data2, len * kind) == 0);
22
515M
}
dictobject.c:unicode_eq
Line
Count
Source
8
61.3M
{
9
61.3M
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
61.3M
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
15.2k
        return 0;
12
15.2k
    }
13
14
61.3M
    int kind = PyUnicode_KIND(str1);
15
61.3M
    if (PyUnicode_KIND(str2) != kind) {
16
0
        return 0;
17
0
    }
18
19
61.3M
    const void *data1 = PyUnicode_DATA(str1);
20
61.3M
    const void *data2 = PyUnicode_DATA(str2);
21
61.3M
    return (memcmp(data1, data2, len * kind) == 0);
22
61.3M
}
setobject.c:unicode_eq
Line
Count
Source
8
387k
{
9
387k
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
387k
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
21
        return 0;
12
21
    }
13
14
387k
    int kind = PyUnicode_KIND(str1);
15
387k
    if (PyUnicode_KIND(str2) != kind) {
16
0
        return 0;
17
0
    }
18
19
387k
    const void *data1 = PyUnicode_DATA(str1);
20
387k
    const void *data2 = PyUnicode_DATA(str2);
21
387k
    return (memcmp(data1, data2, len * kind) == 0);
22
387k
}
unicodeobject.c:unicode_eq
Line
Count
Source
8
559M
{
9
559M
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
559M
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
105M
        return 0;
12
105M
    }
13
14
453M
    int kind = PyUnicode_KIND(str1);
15
453M
    if (PyUnicode_KIND(str2) != kind) {
16
43.4M
        return 0;
17
43.4M
    }
18
19
410M
    const void *data1 = PyUnicode_DATA(str1);
20
410M
    const void *data2 = PyUnicode_DATA(str2);
21
410M
    return (memcmp(data1, data2, len * kind) == 0);
22
453M
}