Enum memchr::memmem::Prefilter

source ·
#[non_exhaustive]
pub enum Prefilter { None, Auto, }
Expand description

Prefilter controls whether heuristics are used to accelerate searching.

A prefilter refers to the idea of detecting candidate matches very quickly, and then confirming whether those candidates are full matches. This idea can be quite effective since it’s often the case that looking for candidates can be a lot faster than running a complete substring search over the entire input. Namely, looking for candidates can be done with extremely fast vectorized code.

The downside of a prefilter is that it assumes false positives (which are candidates generated by a prefilter that aren’t matches) are somewhat rare relative to the frequency of full matches. That is, if a lot of false positives are generated, then it’s possible for search time to be worse than if the prefilter wasn’t enabled in the first place.

Another downside of a prefilter is that it can result in highly variable performance, where some cases are extraordinarily fast and others aren’t. Typically, variable performance isn’t a problem, but it may be for your use case.

The use of prefilters in this implementation does use a heuristic to detect when a prefilter might not be carrying its weight, and will dynamically disable its use. Nevertheless, this configuration option gives callers the ability to disable prefilters if you have knowledge that they won’t be useful.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

None

Never used a prefilter in substring search.

§

Auto

Automatically detect whether a heuristic prefilter should be used. If it is used, then heuristics will be used to dynamically disable the prefilter if it is believed to not be carrying its weight.

Implementations§

source§

impl PrefilterConfig

source

fn is_none(&self) -> bool

Returns true when this prefilter is set to the None variant.

Trait Implementations§

source§

impl Clone for PrefilterConfig

source§

fn clone(&self) -> PrefilterConfig

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for PrefilterConfig

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for PrefilterConfig

source§

fn default() -> PrefilterConfig

Returns the “default value” for a type. Read more
source§

impl Copy for PrefilterConfig

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.