Coverage Report

Created: 2026-05-16 06:46

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
601M
{
9
601M
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
601M
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
117M
        return 0;
12
117M
    }
13
14
484M
    int kind = PyUnicode_KIND(str1);
15
484M
    if (PyUnicode_KIND(str2) != kind) {
16
34.4M
        return 0;
17
34.4M
    }
18
19
449M
    const void *data1 = PyUnicode_DATA(str1);
20
449M
    const void *data2 = PyUnicode_DATA(str2);
21
449M
    return (memcmp(data1, data2, len * kind) == 0);
22
484M
}
dictobject.c:unicode_eq
Line
Count
Source
8
52.1M
{
9
52.1M
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
52.1M
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
25.2k
        return 0;
12
25.2k
    }
13
14
52.0M
    int kind = PyUnicode_KIND(str1);
15
52.0M
    if (PyUnicode_KIND(str2) != kind) {
16
0
        return 0;
17
0
    }
18
19
52.0M
    const void *data1 = PyUnicode_DATA(str1);
20
52.0M
    const void *data2 = PyUnicode_DATA(str2);
21
52.0M
    return (memcmp(data1, data2, len * kind) == 0);
22
52.0M
}
setobject.c:unicode_eq
Line
Count
Source
8
427k
{
9
427k
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
427k
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
12
        return 0;
12
12
    }
13
14
427k
    int kind = PyUnicode_KIND(str1);
15
427k
    if (PyUnicode_KIND(str2) != kind) {
16
0
        return 0;
17
0
    }
18
19
427k
    const void *data1 = PyUnicode_DATA(str1);
20
427k
    const void *data2 = PyUnicode_DATA(str2);
21
427k
    return (memcmp(data1, data2, len * kind) == 0);
22
427k
}
unicodeobject.c:unicode_eq
Line
Count
Source
8
548M
{
9
548M
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
548M
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
117M
        return 0;
12
117M
    }
13
14
431M
    int kind = PyUnicode_KIND(str1);
15
431M
    if (PyUnicode_KIND(str2) != kind) {
16
34.4M
        return 0;
17
34.4M
    }
18
19
397M
    const void *data1 = PyUnicode_DATA(str1);
20
397M
    const void *data2 = PyUnicode_DATA(str2);
21
397M
    return (memcmp(data1, data2, len * kind) == 0);
22
431M
}