Coverage Report

Created: 2025-11-09 07:02

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/cpython3/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
65.9M
{
9
65.9M
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
65.9M
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
779k
        return 0;
12
779k
    }
13
14
65.1M
    int kind = PyUnicode_KIND(str1);
15
130M
    if (PyUnicode_KIND(str2) != kind) {
16
1.09M
        return 0;
17
1.09M
    }
18
19
64.0M
    const void *data1 = PyUnicode_DATA(str1);
20
64.0M
    const void *data2 = PyUnicode_DATA(str2);
21
64.0M
    return (memcmp(data1, data2, len * kind) == 0);
22
65.1M
}
dictobject.c:unicode_eq
Line
Count
Source
8
3.35M
{
9
3.35M
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
3.35M
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
62.8k
        return 0;
12
62.8k
    }
13
14
3.28M
    int kind = PyUnicode_KIND(str1);
15
6.57M
    if (PyUnicode_KIND(str2) != kind) {
16
0
        return 0;
17
0
    }
18
19
3.28M
    const void *data1 = PyUnicode_DATA(str1);
20
3.28M
    const void *data2 = PyUnicode_DATA(str2);
21
3.28M
    return (memcmp(data1, data2, len * kind) == 0);
22
3.28M
}
setobject.c:unicode_eq
Line
Count
Source
8
67.3k
{
9
67.3k
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
67.3k
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
0
        return 0;
12
0
    }
13
14
67.3k
    int kind = PyUnicode_KIND(str1);
15
134k
    if (PyUnicode_KIND(str2) != kind) {
16
0
        return 0;
17
0
    }
18
19
67.3k
    const void *data1 = PyUnicode_DATA(str1);
20
67.3k
    const void *data2 = PyUnicode_DATA(str2);
21
67.3k
    return (memcmp(data1, data2, len * kind) == 0);
22
67.3k
}
unicodeobject.c:unicode_eq
Line
Count
Source
8
62.4M
{
9
62.4M
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
62.4M
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
716k
        return 0;
12
716k
    }
13
14
61.7M
    int kind = PyUnicode_KIND(str1);
15
123M
    if (PyUnicode_KIND(str2) != kind) {
16
1.09M
        return 0;
17
1.09M
    }
18
19
60.6M
    const void *data1 = PyUnicode_DATA(str1);
20
60.6M
    const void *data2 = PyUnicode_DATA(str2);
21
60.6M
    return (memcmp(data1, data2, len * kind) == 0);
22
61.7M
}