Coverage Report

Created: 2025-12-14 07:06

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
577M
{
9
577M
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
577M
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
85.1M
        return 0;
12
85.1M
    }
13
14
492M
    int kind = PyUnicode_KIND(str1);
15
492M
    if (PyUnicode_KIND(str2) != kind) {
16
55.0M
        return 0;
17
55.0M
    }
18
19
436M
    const void *data1 = PyUnicode_DATA(str1);
20
436M
    const void *data2 = PyUnicode_DATA(str2);
21
436M
    return (memcmp(data1, data2, len * kind) == 0);
22
492M
}
dictobject.c:unicode_eq
Line
Count
Source
8
67.7M
{
9
67.7M
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
67.7M
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
7.84k
        return 0;
12
7.84k
    }
13
14
67.7M
    int kind = PyUnicode_KIND(str1);
15
67.7M
    if (PyUnicode_KIND(str2) != kind) {
16
0
        return 0;
17
0
    }
18
19
67.7M
    const void *data1 = PyUnicode_DATA(str1);
20
67.7M
    const void *data2 = PyUnicode_DATA(str2);
21
67.7M
    return (memcmp(data1, data2, len * kind) == 0);
22
67.7M
}
setobject.c:unicode_eq
Line
Count
Source
8
420k
{
9
420k
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
420k
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
3
        return 0;
12
3
    }
13
14
420k
    int kind = PyUnicode_KIND(str1);
15
420k
    if (PyUnicode_KIND(str2) != kind) {
16
0
        return 0;
17
0
    }
18
19
420k
    const void *data1 = PyUnicode_DATA(str1);
20
420k
    const void *data2 = PyUnicode_DATA(str2);
21
420k
    return (memcmp(data1, data2, len * kind) == 0);
22
420k
}
unicodeobject.c:unicode_eq
Line
Count
Source
8
509M
{
9
509M
    Py_ssize_t len = PyUnicode_GET_LENGTH(str1);
10
509M
    if (PyUnicode_GET_LENGTH(str2) != len) {
11
85.1M
        return 0;
12
85.1M
    }
13
14
423M
    int kind = PyUnicode_KIND(str1);
15
423M
    if (PyUnicode_KIND(str2) != kind) {
16
55.0M
        return 0;
17
55.0M
    }
18
19
368M
    const void *data1 = PyUnicode_DATA(str1);
20
368M
    const void *data2 = PyUnicode_DATA(str2);
21
368M
    return (memcmp(data1, data2, len * kind) == 0);
22
423M
}