Coverage Report

Created: 2026-02-09 07:07

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
488M
{
9
488M
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
488M
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
71.2M
        return 0;
12
71.2M
    }
13
14
417M
    int kind = PyUnicode_KIND(str1);
15
417M
    if (PyUnicode_KIND(str2) != kind) {
16
23.0M
        return 0;
17
23.0M
    }
18
19
393M
    const void *data1 = PyUnicode_DATA(str1);
20
393M
    const void *data2 = PyUnicode_DATA(str2);
21
393M
    return (memcmp(data1, data2, len * kind) == 0);
22
417M
}
dictobject.c:unicode_eq
Line
Count
Source
8
68.7M
{
9
68.7M
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
68.7M
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
27.0k
        return 0;
12
27.0k
    }
13
14
68.7M
    int kind = PyUnicode_KIND(str1);
15
68.7M
    if (PyUnicode_KIND(str2) != kind) {
16
0
        return 0;
17
0
    }
18
19
68.7M
    const void *data1 = PyUnicode_DATA(str1);
20
68.7M
    const void *data2 = PyUnicode_DATA(str2);
21
68.7M
    return (memcmp(data1, data2, len * kind) == 0);
22
68.7M
}
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
3
        return 0;
12
3
    }
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
419M
{
9
419M
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
419M
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
71.1M
        return 0;
12
71.1M
    }
13
14
347M
    int kind = PyUnicode_KIND(str1);
15
347M
    if (PyUnicode_KIND(str2) != kind) {
16
23.0M
        return 0;
17
23.0M
    }
18
19
324M
    const void *data1 = PyUnicode_DATA(str1);
20
324M
    const void *data2 = PyUnicode_DATA(str2);
21
324M
    return (memcmp(data1, data2, len * kind) == 0);
22
347M
}