Coverage Report

Created: 2025-07-18 07:04

/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.8k
{
9
55.8k
    PyUnicodeObject *a = (PyUnicodeObject *)aa;
10
55.8k
    PyUnicodeObject *b = (PyUnicodeObject *)bb;
11
12
55.8k
    if (PyUnicode_READY(a) == -1 || PyUnicode_READY(b) == -1) {
13
0
        Py_UNREACHABLE();
14
0
    }
15
16
55.8k
    if (PyUnicode_GET_LENGTH(a) != PyUnicode_GET_LENGTH(b))
17
119
        return 0;
18
55.7k
    if (PyUnicode_GET_LENGTH(a) == 0)
19
0
        return 1;
20
55.7k
    if (PyUnicode_KIND(a) != PyUnicode_KIND(b))
21
0
        return 0;
22
55.7k
    return memcmp(PyUnicode_1BYTE_DATA(a), PyUnicode_1BYTE_DATA(b),
23
55.7k
                  PyUnicode_GET_LENGTH(a) * PyUnicode_KIND(a)) == 0;
24
55.7k
}
dictobject.c:unicode_eq
Line
Count
Source
8
55.4k
{
9
55.4k
    PyUnicodeObject *a = (PyUnicodeObject *)aa;
10
55.4k
    PyUnicodeObject *b = (PyUnicodeObject *)bb;
11
12
55.4k
    if (PyUnicode_READY(a) == -1 || PyUnicode_READY(b) == -1) {
13
0
        Py_UNREACHABLE();
14
0
    }
15
16
55.4k
    if (PyUnicode_GET_LENGTH(a) != PyUnicode_GET_LENGTH(b))
17
0
        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
}
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
}