Coverage Report

Created: 2025-11-30 06:38

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/cpython/Objects/stringlib/find.h
Line
Count
Source
1
/* stringlib: find/index implementation */
2
3
#ifndef STRINGLIB_FASTSEARCH_H
4
#error must include "stringlib/fastsearch.h" before including this module
5
#endif
6
7
Py_LOCAL_INLINE(Py_ssize_t)
8
STRINGLIB(find)(const STRINGLIB_CHAR* str, Py_ssize_t str_len,
9
               const STRINGLIB_CHAR* sub, Py_ssize_t sub_len,
10
               Py_ssize_t offset)
11
160M
{
12
160M
    Py_ssize_t pos;
13
14
160M
    assert(str_len >= 0);
15
160M
    if (sub_len == 0)
16
0
        return offset;
17
18
160M
    pos = FASTSEARCH(str, str_len, sub, sub_len, -1, FAST_SEARCH);
19
20
160M
    if (pos >= 0)
21
154M
        pos += offset;
22
23
160M
    return pos;
24
160M
}
Unexecuted instantiation: bytesobject.c:stringlib_find
unicodeobject.c:asciilib_find
Line
Count
Source
11
20.0M
{
12
20.0M
    Py_ssize_t pos;
13
14
20.0M
    assert(str_len >= 0);
15
20.0M
    if (sub_len == 0)
16
0
        return offset;
17
18
20.0M
    pos = FASTSEARCH(str, str_len, sub, sub_len, -1, FAST_SEARCH);
19
20
20.0M
    if (pos >= 0)
21
20.0M
        pos += offset;
22
23
20.0M
    return pos;
24
20.0M
}
unicodeobject.c:ucs1lib_find
Line
Count
Source
11
11.2M
{
12
11.2M
    Py_ssize_t pos;
13
14
11.2M
    assert(str_len >= 0);
15
11.2M
    if (sub_len == 0)
16
0
        return offset;
17
18
11.2M
    pos = FASTSEARCH(str, str_len, sub, sub_len, -1, FAST_SEARCH);
19
20
11.2M
    if (pos >= 0)
21
4.54M
        pos += offset;
22
23
11.2M
    return pos;
24
11.2M
}
unicodeobject.c:ucs2lib_find
Line
Count
Source
11
69.7M
{
12
69.7M
    Py_ssize_t pos;
13
14
69.7M
    assert(str_len >= 0);
15
69.7M
    if (sub_len == 0)
16
0
        return offset;
17
18
69.7M
    pos = FASTSEARCH(str, str_len, sub, sub_len, -1, FAST_SEARCH);
19
20
69.7M
    if (pos >= 0)
21
69.7M
        pos += offset;
22
23
69.7M
    return pos;
24
69.7M
}
unicodeobject.c:ucs4lib_find
Line
Count
Source
11
59.8M
{
12
59.8M
    Py_ssize_t pos;
13
14
59.8M
    assert(str_len >= 0);
15
59.8M
    if (sub_len == 0)
16
0
        return offset;
17
18
59.8M
    pos = FASTSEARCH(str, str_len, sub, sub_len, -1, FAST_SEARCH);
19
20
59.8M
    if (pos >= 0)
21
59.8M
        pos += offset;
22
23
59.8M
    return pos;
24
59.8M
}
bytes_methods.c:stringlib_find
Line
Count
Source
11
2.77k
{
12
2.77k
    Py_ssize_t pos;
13
14
2.77k
    assert(str_len >= 0);
15
2.77k
    if (sub_len == 0)
16
0
        return offset;
17
18
2.77k
    pos = FASTSEARCH(str, str_len, sub, sub_len, -1, FAST_SEARCH);
19
20
2.77k
    if (pos >= 0)
21
2.53k
        pos += offset;
22
23
2.77k
    return pos;
24
2.77k
}
Unexecuted instantiation: bytearrayobject.c:stringlib_find
25
26
Py_LOCAL_INLINE(Py_ssize_t)
27
STRINGLIB(rfind)(const STRINGLIB_CHAR* str, Py_ssize_t str_len,
28
                const STRINGLIB_CHAR* sub, Py_ssize_t sub_len,
29
                Py_ssize_t offset)
30
6.55k
{
31
6.55k
    Py_ssize_t pos;
32
33
6.55k
    assert(str_len >= 0);
34
6.55k
    if (sub_len == 0)
35
0
        return str_len + offset;
36
37
6.55k
    pos = FASTSEARCH(str, str_len, sub, sub_len, -1, FAST_RSEARCH);
38
39
6.55k
    if (pos >= 0)
40
6.46k
        pos += offset;
41
42
6.55k
    return pos;
43
6.55k
}
Unexecuted instantiation: bytesobject.c:stringlib_rfind
Unexecuted instantiation: unicodeobject.c:asciilib_rfind
Unexecuted instantiation: unicodeobject.c:ucs1lib_rfind
Unexecuted instantiation: unicodeobject.c:ucs2lib_rfind
Unexecuted instantiation: unicodeobject.c:ucs4lib_rfind
bytes_methods.c:stringlib_rfind
Line
Count
Source
30
6.55k
{
31
6.55k
    Py_ssize_t pos;
32
33
6.55k
    assert(str_len >= 0);
34
6.55k
    if (sub_len == 0)
35
0
        return str_len + offset;
36
37
6.55k
    pos = FASTSEARCH(str, str_len, sub, sub_len, -1, FAST_RSEARCH);
38
39
6.55k
    if (pos >= 0)
40
6.46k
        pos += offset;
41
42
6.55k
    return pos;
43
6.55k
}
Unexecuted instantiation: bytearrayobject.c:stringlib_rfind
44
45
Py_LOCAL_INLINE(Py_ssize_t)
46
STRINGLIB(find_slice)(const STRINGLIB_CHAR* str, Py_ssize_t str_len,
47
                     const STRINGLIB_CHAR* sub, Py_ssize_t sub_len,
48
                     Py_ssize_t start, Py_ssize_t end)
49
54.7k
{
50
54.7k
    return STRINGLIB(find)(str + start, end - start, sub, sub_len, start);
51
54.7k
}
Unexecuted instantiation: bytesobject.c:stringlib_find_slice
unicodeobject.c:asciilib_find_slice
Line
Count
Source
49
4.57k
{
50
4.57k
    return STRINGLIB(find)(str + start, end - start, sub, sub_len, start);
51
4.57k
}
unicodeobject.c:ucs1lib_find_slice
Line
Count
Source
49
9.91k
{
50
9.91k
    return STRINGLIB(find)(str + start, end - start, sub, sub_len, start);
51
9.91k
}
unicodeobject.c:ucs2lib_find_slice
Line
Count
Source
49
20.1k
{
50
20.1k
    return STRINGLIB(find)(str + start, end - start, sub, sub_len, start);
51
20.1k
}
unicodeobject.c:ucs4lib_find_slice
Line
Count
Source
49
20.0k
{
50
20.0k
    return STRINGLIB(find)(str + start, end - start, sub, sub_len, start);
51
20.0k
}
Unexecuted instantiation: bytes_methods.c:stringlib_find_slice
Unexecuted instantiation: bytearrayobject.c:stringlib_find_slice
52
53
Py_LOCAL_INLINE(Py_ssize_t)
54
STRINGLIB(rfind_slice)(const STRINGLIB_CHAR* str, Py_ssize_t str_len,
55
                      const STRINGLIB_CHAR* sub, Py_ssize_t sub_len,
56
                      Py_ssize_t start, Py_ssize_t end)
57
6.55k
{
58
6.55k
    return STRINGLIB(rfind)(str + start, end - start, sub, sub_len, start);
59
6.55k
}
Unexecuted instantiation: bytesobject.c:stringlib_rfind_slice
Unexecuted instantiation: unicodeobject.c:asciilib_rfind_slice
Unexecuted instantiation: unicodeobject.c:ucs1lib_rfind_slice
Unexecuted instantiation: unicodeobject.c:ucs2lib_rfind_slice
Unexecuted instantiation: unicodeobject.c:ucs4lib_rfind_slice
bytes_methods.c:stringlib_rfind_slice
Line
Count
Source
57
6.55k
{
58
6.55k
    return STRINGLIB(rfind)(str + start, end - start, sub, sub_len, start);
59
6.55k
}
Unexecuted instantiation: bytearrayobject.c:stringlib_rfind_slice
60
61
#ifdef STRINGLIB_WANT_CONTAINS_OBJ
62
63
Py_LOCAL_INLINE(int)
64
STRINGLIB(contains_obj)(PyObject* str, PyObject* sub)
65
{
66
    return STRINGLIB(find)(
67
        STRINGLIB_STR(str), STRINGLIB_LEN(str),
68
        STRINGLIB_STR(sub), STRINGLIB_LEN(sub), 0
69
        ) != -1;
70
}
71
72
#endif /* STRINGLIB_WANT_CONTAINS_OBJ */