Coverage Report

Created: 2026-02-26 06:53

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
655M
{
9
655M
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
655M
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
75.0M
        return 0;
12
75.0M
    }
13
14
580M
    int kind = PyUnicode_KIND(str1);
15
580M
    if (PyUnicode_KIND(str2) != kind) {
16
33.6M
        return 0;
17
33.6M
    }
18
19
546M
    const void *data1 = PyUnicode_DATA(str1);
20
546M
    const void *data2 = PyUnicode_DATA(str2);
21
546M
    return (memcmp(data1, data2, len * kind) == 0);
22
580M
}
dictobject.c:unicode_eq
Line
Count
Source
8
83.9M
{
9
83.9M
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
83.9M
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
25.8k
        return 0;
12
25.8k
    }
13
14
83.8M
    int kind = PyUnicode_KIND(str1);
15
83.8M
    if (PyUnicode_KIND(str2) != kind) {
16
0
        return 0;
17
0
    }
18
19
83.8M
    const void *data1 = PyUnicode_DATA(str1);
20
83.8M
    const void *data2 = PyUnicode_DATA(str2);
21
83.8M
    return (memcmp(data1, data2, len * kind) == 0);
22
83.8M
}
setobject.c:unicode_eq
Line
Count
Source
8
460k
{
9
460k
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
460k
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
3
        return 0;
12
3
    }
13
14
460k
    int kind = PyUnicode_KIND(str1);
15
460k
    if (PyUnicode_KIND(str2) != kind) {
16
0
        return 0;
17
0
    }
18
19
460k
    const void *data1 = PyUnicode_DATA(str1);
20
460k
    const void *data2 = PyUnicode_DATA(str2);
21
460k
    return (memcmp(data1, data2, len * kind) == 0);
22
460k
}
unicodeobject.c:unicode_eq
Line
Count
Source
8
570M
{
9
570M
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
570M
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
75.0M
        return 0;
12
75.0M
    }
13
14
495M
    int kind = PyUnicode_KIND(str1);
15
495M
    if (PyUnicode_KIND(str2) != kind) {
16
33.6M
        return 0;
17
33.6M
    }
18
19
462M
    const void *data1 = PyUnicode_DATA(str1);
20
462M
    const void *data2 = PyUnicode_DATA(str2);
21
462M
    return (memcmp(data1, data2, len * kind) == 0);
22
495M
}