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
table: Vec<SuffixCacheEntry>
version: usize
Methods
impl SuffixCache[src]
impl SuffixCachefn new(size: usize) -> Self[src]
fn new(size: usize) -> Selffn get(&mut self, key: SuffixCacheKey, pc: usize) -> Option<usize>[src]
fn get(&mut self, key: SuffixCacheKey, pc: usize) -> Option<usize>fn clear(&mut self)[src]
fn clear(&mut self)fn hash(&self, suffix: &SuffixCacheKey) -> usize[src]
fn hash(&self, suffix: &SuffixCacheKey) -> usizeAuto Trait Implementations
impl Send for SuffixCache
impl Send for SuffixCacheimpl Sync for SuffixCache
impl Sync for SuffixCache