Coverage Report

Created: 2025-11-09 06:26

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
279M
{
9
279M
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
279M
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
87.7M
        return 0;
12
87.7M
    }
13
14
191M
    int kind = PyUnicode_KIND(str1);
15
191M
    if (PyUnicode_KIND(str2) != kind) {
16
8.54M
        return 0;
17
8.54M
    }
18
19
182M
    const void *data1 = PyUnicode_DATA(str1);
20
182M
    const void *data2 = PyUnicode_DATA(str2);
21
182M
    return (memcmp(data1, data2, len * kind) == 0);
22
191M
}
dictobject.c:unicode_eq
Line
Count
Source
8
42.0M
{
9
42.0M
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
42.0M
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
11.6k
        return 0;
12
11.6k
    }
13
14
42.0M
    int kind = PyUnicode_KIND(str1);
15
42.0M
    if (PyUnicode_KIND(str2) != kind) {
16
0
        return 0;
17
0
    }
18
19
42.0M
    const void *data1 = PyUnicode_DATA(str1);
20
42.0M
    const void *data2 = PyUnicode_DATA(str2);
21
42.0M
    return (memcmp(data1, data2, len * kind) == 0);
22
42.0M
}
setobject.c:unicode_eq
Line
Count
Source
8
297k
{
9
297k
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
297k
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
3
        return 0;
12
3
    }
13
14
297k
    int kind = PyUnicode_KIND(str1);
15
297k
    if (PyUnicode_KIND(str2) != kind) {
16
0
        return 0;
17
0
    }
18
19
297k
    const void *data1 = PyUnicode_DATA(str1);
20
297k
    const void *data2 = PyUnicode_DATA(str2);
21
297k
    return (memcmp(data1, data2, len * kind) == 0);
22
297k
}
unicodeobject.c:unicode_eq
Line
Count
Source
8
236M
{
9
236M
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
236M
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
87.7M
        return 0;
12
87.7M
    }
13
14
149M
    int kind = PyUnicode_KIND(str1);
15
149M
    if (PyUnicode_KIND(str2) != kind) {
16
8.54M
        return 0;
17
8.54M
    }
18
19
140M
    const void *data1 = PyUnicode_DATA(str1);
20
140M
    const void *data2 = PyUnicode_DATA(str2);
21
140M
    return (memcmp(data1, data2, len * kind) == 0);
22
149M
}