Coverage Report

Created: 2026-03-23 06:45

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
567M
{
9
567M
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
567M
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
105M
        return 0;
12
105M
    }
13
14
461M
    int kind = PyUnicode_KIND(str1);
15
461M
    if (PyUnicode_KIND(str2) != kind) {
16
28.7M
        return 0;
17
28.7M
    }
18
19
433M
    const void *data1 = PyUnicode_DATA(str1);
20
433M
    const void *data2 = PyUnicode_DATA(str2);
21
433M
    return (memcmp(data1, data2, len * kind) == 0);
22
461M
}
dictobject.c:unicode_eq
Line
Count
Source
8
62.0M
{
9
62.0M
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
62.0M
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
19.7k
        return 0;
12
19.7k
    }
13
14
61.9M
    int kind = PyUnicode_KIND(str1);
15
61.9M
    if (PyUnicode_KIND(str2) != kind) {
16
0
        return 0;
17
0
    }
18
19
61.9M
    const void *data1 = PyUnicode_DATA(str1);
20
61.9M
    const void *data2 = PyUnicode_DATA(str2);
21
61.9M
    return (memcmp(data1, data2, len * kind) == 0);
22
61.9M
}
setobject.c:unicode_eq
Line
Count
Source
8
430k
{
9
430k
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
430k
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
11
        return 0;
12
11
    }
13
14
430k
    int kind = PyUnicode_KIND(str1);
15
430k
    if (PyUnicode_KIND(str2) != kind) {
16
0
        return 0;
17
0
    }
18
19
430k
    const void *data1 = PyUnicode_DATA(str1);
20
430k
    const void *data2 = PyUnicode_DATA(str2);
21
430k
    return (memcmp(data1, data2, len * kind) == 0);
22
430k
}
unicodeobject.c:unicode_eq
Line
Count
Source
8
504M
{
9
504M
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
504M
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
105M
        return 0;
12
105M
    }
13
14
399M
    int kind = PyUnicode_KIND(str1);
15
399M
    if (PyUnicode_KIND(str2) != kind) {
16
28.7M
        return 0;
17
28.7M
    }
18
19
370M
    const void *data1 = PyUnicode_DATA(str1);
20
370M
    const void *data2 = PyUnicode_DATA(str2);
21
370M
    return (memcmp(data1, data2, len * kind) == 0);
22
399M
}