Coverage Report

Created: 2026-05-30 06:18

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
612M
{
9
612M
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
612M
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
122M
        return 0;
12
122M
    }
13
14
490M
    int kind = PyUnicode_KIND(str1);
15
490M
    if (PyUnicode_KIND(str2) != kind) {
16
35.0M
        return 0;
17
35.0M
    }
18
19
455M
    const void *data1 = PyUnicode_DATA(str1);
20
455M
    const void *data2 = PyUnicode_DATA(str2);
21
455M
    return (memcmp(data1, data2, len * kind) == 0);
22
490M
}
dictobject.c:unicode_eq
Line
Count
Source
8
53.8M
{
9
53.8M
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
53.8M
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
26.0k
        return 0;
12
26.0k
    }
13
14
53.8M
    int kind = PyUnicode_KIND(str1);
15
53.8M
    if (PyUnicode_KIND(str2) != kind) {
16
0
        return 0;
17
0
    }
18
19
53.8M
    const void *data1 = PyUnicode_DATA(str1);
20
53.8M
    const void *data2 = PyUnicode_DATA(str2);
21
53.8M
    return (memcmp(data1, data2, len * kind) == 0);
22
53.8M
}
setobject.c:unicode_eq
Line
Count
Source
8
383k
{
9
383k
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
383k
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
14
        return 0;
12
14
    }
13
14
383k
    int kind = PyUnicode_KIND(str1);
15
383k
    if (PyUnicode_KIND(str2) != kind) {
16
0
        return 0;
17
0
    }
18
19
383k
    const void *data1 = PyUnicode_DATA(str1);
20
383k
    const void *data2 = PyUnicode_DATA(str2);
21
383k
    return (memcmp(data1, data2, len * kind) == 0);
22
383k
}
unicodeobject.c:unicode_eq
Line
Count
Source
8
558M
{
9
558M
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
558M
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
122M
        return 0;
12
122M
    }
13
14
436M
    int kind = PyUnicode_KIND(str1);
15
436M
    if (PyUnicode_KIND(str2) != kind) {
16
35.0M
        return 0;
17
35.0M
    }
18
19
401M
    const void *data1 = PyUnicode_DATA(str1);
20
401M
    const void *data2 = PyUnicode_DATA(str2);
21
401M
    return (memcmp(data1, data2, len * kind) == 0);
22
436M
}