-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Closed
Labels
Description
For example, findfirst("abc", "ab") eventually ends up calling:
function _searchindex(s::String, t::String, i::Integer)
# Check for fast case of a single byte
lastindex(t) == 1 && return something(findnext(isequal(t[1]), s, i), 0)
_searchindex(unsafe_wrap(Vector{UInt8},s), unsafe_wrap(Vector{UInt8},t), i)
endThe unsafe_wrap allocates, which slows down string search.
However, when I tried replacing the unsafe_wrap(Vector{UInt8}, ::String) with codeunits(::String), Julia failed to bootstrap.
There are a number of similar unsafe_wrap calls in the same file.
It would be nice to remove this allocation, somehow.
giordano, ianatol, jlapeyre, nickrobinson251, jacob-roth and 1 more