Coverage Report

Created: 2025-10-10 06:33

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
264M
{
9
264M
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
264M
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
64.6M
        return 0;
12
64.6M
    }
13
14
200M
    int kind = PyUnicode_KIND(str1);
15
200M
    if (PyUnicode_KIND(str2) != kind) {
16
22.8M
        return 0;
17
22.8M
    }
18
19
177M
    const void *data1 = PyUnicode_DATA(str1);
20
177M
    const void *data2 = PyUnicode_DATA(str2);
21
177M
    return (memcmp(data1, data2, len * kind) == 0);
22
200M
}
dictobject.c:unicode_eq
Line
Count
Source
8
41.6M
{
9
41.6M
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
41.6M
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
11.9k
        return 0;
12
11.9k
    }
13
14
41.6M
    int kind = PyUnicode_KIND(str1);
15
41.6M
    if (PyUnicode_KIND(str2) != kind) {
16
0
        return 0;
17
0
    }
18
19
41.6M
    const void *data1 = PyUnicode_DATA(str1);
20
41.6M
    const void *data2 = PyUnicode_DATA(str2);
21
41.6M
    return (memcmp(data1, data2, len * kind) == 0);
22
41.6M
}
setobject.c:unicode_eq
Line
Count
Source
8
326k
{
9
326k
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
326k
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
3
        return 0;
12
3
    }
13
14
326k
    int kind = PyUnicode_KIND(str1);
15
326k
    if (PyUnicode_KIND(str2) != kind) {
16
0
        return 0;
17
0
    }
18
19
326k
    const void *data1 = PyUnicode_DATA(str1);
20
326k
    const void *data2 = PyUnicode_DATA(str2);
21
326k
    return (memcmp(data1, data2, len * kind) == 0);
22
326k
}
unicodeobject.c:unicode_eq
Line
Count
Source
8
222M
{
9
222M
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
222M
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
64.5M
        return 0;
12
64.5M
    }
13
14
158M
    int kind = PyUnicode_KIND(str1);
15
158M
    if (PyUnicode_KIND(str2) != kind) {
16
22.8M
        return 0;
17
22.8M
    }
18
19
135M
    const void *data1 = PyUnicode_DATA(str1);
20
135M
    const void *data2 = PyUnicode_DATA(str2);
21
135M
    return (memcmp(data1, data2, len * kind) == 0);
22
158M
}