|
77 | 77 | # The following functions require julia#37283 in Julia 1.6, which
|
78 | 78 | # allow us to search byte arrays (applied to codeunits(s)).
|
79 | 79 | @static if VERSION ≥ v"1.6.0-DEV.1341"
|
80 |
| - function Base._searchindex(s::Union{StringViewAndSub,StringAndSub}, t::Union{StringViewAndSub,StringAndSub}, i::Integer) |
| 80 | + # Split into two identical methods to avoid pirating Base's methods, leading to ~370 invalidations. |
| 81 | + function Base._searchindex(s::StringViewAndSub, t::Union{StringViewAndSub,StringAndSub}, i::Integer) |
| 82 | + searchindex_internal(s, t, i) |
| 83 | + end |
| 84 | + |
| 85 | + function Base._searchindex(s::Union{StringViewAndSub,StringAndSub}, t::StringViewAndSub, i::Integer) |
| 86 | + searchindex_internal(s, t, i) |
| 87 | + end |
| 88 | + |
| 89 | + function searchindex_internal(s::Union{StringViewAndSub,StringAndSub}, t::Union{StringViewAndSub,StringAndSub}, i::Integer) |
81 | 90 | # Check for fast case of a single byte
|
82 | 91 | lastindex(t) == 1 && return something(findnext(isequal(t[1]), s, i), 0)
|
83 | 92 | Base._searchindex(codeunits(s), codeunits(t), i)
|
84 | 93 | end
|
85 |
| - function Base._rsearchindex(s::Union{StringViewAndSub,StringAndSub}, t::Union{StringViewAndSub,StringAndSub}, i::Integer) |
| 94 | + |
| 95 | + function Base._rsearchindex(s::StringViewAndSub, t::Union{StringViewAndSub,StringAndSub}, i::Integer) |
| 96 | + rsearchindex_internal(s, t, i) |
| 97 | + end |
| 98 | + |
| 99 | + function Base._rsearchindex(s::Union{StringViewAndSub,StringAndSub}, t::StringViewAndSub, i::Integer) |
| 100 | + rsearchindex_internal(s, t, i) |
| 101 | + end |
| 102 | + |
| 103 | + function rsearchindex_internal(s::Union{StringViewAndSub,StringAndSub}, t::Union{StringViewAndSub,StringAndSub}, i::Integer) |
86 | 104 | # Check for fast case of a single byte
|
87 | 105 | if lastindex(t) == 1
|
88 | 106 | return something(findprev(isequal(t[1]), s, i), 0)
|
|
0 commit comments