Struct regex::literal::FreqyPacked[][src]

pub struct FreqyPacked {
    pat: Vec<u8>,
    char_len: usize,
    rare1: u8,
    rare1i: usize,
    rare2: u8,
    rare2i: usize,
}

Provides an implementation of fast subtring search using frequency analysis.

memchr is so fast that we do everything we can to keep the loop in memchr for as long as possible. The easiest way to do this is to intelligently pick the byte to send to memchr. The best byte is the byte that occurs least frequently in the haystack. Since doing frequency analysis on the haystack is far too expensive, we compute a set of fixed frequencies up front and hard code them in src/freqs.rs. Frequency analysis is done via scripts/frequencies.py.

Fields

The pattern.

The number of Unicode characters in the pattern. This is useful for determining the effective length of a pattern when deciding which optimizations to perform. A trailing incomplete UTF-8 sequence counts as one character.

The rarest byte in the pattern, according to pre-computed frequency analysis.

The offset of the rarest byte in pat.

The second rarest byte in the pattern, according to pre-computed frequency analysis. (This may be equivalent to the rarest byte.)

The second rarest byte is used as a type of guard for quickly detecting a mismatch after memchr locates an instance of the rarest byte. This is a hedge against pathological cases where the pre-computed frequency analysis may be off. (But of course, does not prevent all pathological cases.)

The offset of the second rarest byte in pat.

Methods

impl FreqyPacked
[src]

Trait Implementations

impl Clone for FreqyPacked
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Debug for FreqyPacked
[src]

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl Send for FreqyPacked

impl Sync for FreqyPacked