Coverage Report

Created: 2025-07-11 06:59

/src/Python-3.8.3/Objects/stringlib/eq.h
Line
Count
Source (jump to first uncovered line)
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 *aa, PyObject *bb)
8
55.5k
{
9
55.5k
    PyUnicodeObject *a = (PyUnicodeObject *)aa;
10
55.5k
    PyUnicodeObject *b = (PyUnicodeObject *)bb;
11
12
55.5k
    if (PyUnicode_READY(a) == -1 || PyUnicode_READY(b) == -1) {
13
0
        Py_UNREACHABLE();
14
0
    }
15
16
55.5k
    if (PyUnicode_GET_LENGTH(a) != PyUnicode_GET_LENGTH(b))
17
119
        return 0;
18
55.4k
    if (PyUnicode_GET_LENGTH(a) == 0)
19
0
        return 1;
20
55.4k
    if (PyUnicode_KIND(a) != PyUnicode_KIND(b))
21
0
        return 0;
22
55.4k
    return memcmp(PyUnicode_1BYTE_DATA(a), PyUnicode_1BYTE_DATA(b),
23
55.4k
                  PyUnicode_GET_LENGTH(a) * PyUnicode_KIND(a)) == 0;
24
55.4k
}
dictobject.c:unicode_eq
Line
Count
Source
8
55.1k
{
9
55.1k
    PyUnicodeObject *a = (PyUnicodeObject *)aa;
10
55.1k
    PyUnicodeObject *b = (PyUnicodeObject *)bb;
11
12
55.1k
    if (PyUnicode_READY(a) == -1 || PyUnicode_READY(b) == -1) {
13
0
        Py_UNREACHABLE();
14
0
    }
15
16
55.1k
    if (PyUnicode_GET_LENGTH(a) != PyUnicode_GET_LENGTH(b))
17
0
        return 0;
18
55.1k
    if (PyUnicode_GET_LENGTH(a) == 0)
19
0
        return 1;
20
55.1k
    if (PyUnicode_KIND(a) != PyUnicode_KIND(b))
21
0
        return 0;
22
55.1k
    return memcmp(PyUnicode_1BYTE_DATA(a), PyUnicode_1BYTE_DATA(b),
23
55.1k
                  PyUnicode_GET_LENGTH(a) * PyUnicode_KIND(a)) == 0;
24
55.1k
}
unicodeobject.c:unicode_eq
Line
Count
Source
8
424
{
9
424
    PyUnicodeObject *a = (PyUnicodeObject *)aa;
10
424
    PyUnicodeObject *b = (PyUnicodeObject *)bb;
11
12
424
    if (PyUnicode_READY(a) == -1 || PyUnicode_READY(b) == -1) {
13
0
        Py_UNREACHABLE();
14
0
    }
15
16
424
    if (PyUnicode_GET_LENGTH(a) != PyUnicode_GET_LENGTH(b))
17
119
        return 0;
18
305
    if (PyUnicode_GET_LENGTH(a) == 0)
19
0
        return 1;
20
305
    if (PyUnicode_KIND(a) != PyUnicode_KIND(b))
21
0
        return 0;
22
305
    return memcmp(PyUnicode_1BYTE_DATA(a), PyUnicode_1BYTE_DATA(b),
23
305
                  PyUnicode_GET_LENGTH(a) * PyUnicode_KIND(a)) == 0;
24
305
}