Function memchr::memmem::searcher::do_packed_search

source ยท
fn do_packed_search(needle: &[u8]) -> bool
Expand description

Returns true if the needle has the right characteristics for a vector algorithm to handle the entirety of substring search.

Vector algorithms can be used for prefilters for other substring search algorithms (like Two-Way), but they can also be used for substring search on their own. When used for substring search, vector algorithms will quickly identify candidate match positions (just like in the prefilter case), but instead of returning the candidate position they will try to confirm the match themselves. Confirmation happens via memcmp. This works well for short needles, but can break down when many false candidate positions are generated for large needles. Thus, we only permit vector algorithms to own substring search when the needle is of a certain length.