Coverage Report

Created: 2025-11-24 06:11

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
628M
{
9
628M
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
628M
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
87.5M
        return 0;
12
87.5M
    }
13
14
540M
    int kind = PyUnicode_KIND(str1);
15
540M
    if (PyUnicode_KIND(str2) != kind) {
16
36.9M
        return 0;
17
36.9M
    }
18
19
503M
    const void *data1 = PyUnicode_DATA(str1);
20
503M
    const void *data2 = PyUnicode_DATA(str2);
21
503M
    return (memcmp(data1, data2, len * kind) == 0);
22
540M
}
dictobject.c:unicode_eq
Line
Count
Source
8
78.5M
{
9
78.5M
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
78.5M
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
11.1k
        return 0;
12
11.1k
    }
13
14
78.5M
    int kind = PyUnicode_KIND(str1);
15
78.5M
    if (PyUnicode_KIND(str2) != kind) {
16
0
        return 0;
17
0
    }
18
19
78.5M
    const void *data1 = PyUnicode_DATA(str1);
20
78.5M
    const void *data2 = PyUnicode_DATA(str2);
21
78.5M
    return (memcmp(data1, data2, len * kind) == 0);
22
78.5M
}
setobject.c:unicode_eq
Line
Count
Source
8
455k
{
9
455k
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
455k
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
6
        return 0;
12
6
    }
13
14
455k
    int kind = PyUnicode_KIND(str1);
15
455k
    if (PyUnicode_KIND(str2) != kind) {
16
0
        return 0;
17
0
    }
18
19
455k
    const void *data1 = PyUnicode_DATA(str1);
20
455k
    const void *data2 = PyUnicode_DATA(str2);
21
455k
    return (memcmp(data1, data2, len * kind) == 0);
22
455k
}
unicodeobject.c:unicode_eq
Line
Count
Source
8
549M
{
9
549M
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
549M
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
87.5M
        return 0;
12
87.5M
    }
13
14
461M
    int kind = PyUnicode_KIND(str1);
15
461M
    if (PyUnicode_KIND(str2) != kind) {
16
36.9M
        return 0;
17
36.9M
    }
18
19
424M
    const void *data1 = PyUnicode_DATA(str1);
20
424M
    const void *data2 = PyUnicode_DATA(str2);
21
424M
    return (memcmp(data1, data2, len * kind) == 0);
22
461M
}