Struct regex::compile::SuffixCache[][src]

struct SuffixCache {
    table: Vec<SuffixCacheEntry>,
    version: usize,
}

SuffixCache is a simple bounded hash map for caching suffix entries in UTF-8 automata. For example, consider the Unicode range \u{0}-\u{FFFF}. The set of byte ranges looks like this:

[0-7F] [C2-DF][80-BF] [E0][A0-BF][80-BF] [E1-EC][80-BF][80-BF] [ED][80-9F][80-BF] [EE-EF][80-BF][80-BF]

Each line above translates to one alternate in the compiled regex program. However, all but one of the alternates end in the same suffix, which is a waste of an instruction. The suffix cache facilitates reusing them across alternates.

Note that a HashMap could be trivially used for this, but we don't need its overhead. Some small bounded space (LRU style) is more than enough.

Fields

Methods

impl SuffixCache
[src]

Auto Trait Implementations

impl Send for SuffixCache

impl Sync for SuffixCache