Coverage Report

Created: 2025-11-24 06:34

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
71.0M
{
9
71.0M
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
71.0M
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
664k
        return 0;
12
664k
    }
13
14
70.4M
    int kind = PyUnicode_KIND(str1);
15
140M
    if (PyUnicode_KIND(str2) != kind) {
16
929k
        return 0;
17
929k
    }
18
19
69.4M
    const void *data1 = PyUnicode_DATA(str1);
20
69.4M
    const void *data2 = PyUnicode_DATA(str2);
21
69.4M
    return (memcmp(data1, data2, len * kind) == 0);
22
70.4M
}
dictobject.c:unicode_eq
Line
Count
Source
8
3.24M
{
9
3.24M
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
3.24M
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
76.7k
        return 0;
12
76.7k
    }
13
14
3.16M
    int kind = PyUnicode_KIND(str1);
15
6.33M
    if (PyUnicode_KIND(str2) != kind) {
16
0
        return 0;
17
0
    }
18
19
3.16M
    const void *data1 = PyUnicode_DATA(str1);
20
3.16M
    const void *data2 = PyUnicode_DATA(str2);
21
3.16M
    return (memcmp(data1, data2, len * kind) == 0);
22
3.16M
}
setobject.c:unicode_eq
Line
Count
Source
8
44.4k
{
9
44.4k
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
44.4k
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
0
        return 0;
12
0
    }
13
14
44.4k
    int kind = PyUnicode_KIND(str1);
15
88.9k
    if (PyUnicode_KIND(str2) != kind) {
16
0
        return 0;
17
0
    }
18
19
44.4k
    const void *data1 = PyUnicode_DATA(str1);
20
44.4k
    const void *data2 = PyUnicode_DATA(str2);
21
44.4k
    return (memcmp(data1, data2, len * kind) == 0);
22
44.4k
}
unicodeobject.c:unicode_eq
Line
Count
Source
8
67.8M
{
9
67.8M
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
67.8M
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
587k
        return 0;
12
587k
    }
13
14
67.2M
    int kind = PyUnicode_KIND(str1);
15
134M
    if (PyUnicode_KIND(str2) != kind) {
16
929k
        return 0;
17
929k
    }
18
19
66.2M
    const void *data1 = PyUnicode_DATA(str1);
20
66.2M
    const void *data2 = PyUnicode_DATA(str2);
21
66.2M
    return (memcmp(data1, data2, len * kind) == 0);
22
67.2M
}