Struct regex::exec::ExecReadOnly [−][src]
struct ExecReadOnly { res: Vec<String>, nfa: Program, dfa: Program, dfa_reverse: Program, suffixes: LiteralSearcher, match_type: MatchType, }
ExecReadOnly
comprises all read only state for a regex. Namely, all such
state is determined at compile time and never changes during search.
Fields
res: Vec<String>
The original regular expressions given by the caller to compile.
nfa: Program
A compiled program that is used in the NFA simulation and backtracking. It can be byte-based or Unicode codepoint based.
N.B. It is not possibly to make this byte-based from the public API. It is only used for testing byte based programs in the NFA simulations.
dfa: Program
A compiled byte based program for DFA execution. This is only used
if a DFA can be executed. (Currently, only word boundary assertions are
not supported.) Note that this program contains an embedded .*?
preceding the first capture group, unless the regex is anchored at the
beginning.
dfa_reverse: Program
The same as above, except the program is reversed (and there is no
preceding .*?
). This is used by the DFA to find the starting location
of matches.
suffixes: LiteralSearcher
A set of suffix literals extracted from the regex.
Prefix literals are stored on the Program
, since they are used inside
the matching engines.
match_type: MatchType
match_type encodes as much upfront knowledge about how we're going to execute a search as possible.
Methods
impl ExecReadOnly
[src]
impl ExecReadOnly
fn choose_match_type(&self, hint: Option<MatchType>) -> MatchType
[src]
fn choose_match_type(&self, hint: Option<MatchType>) -> MatchType
fn should_suffix_scan(&self) -> bool
[src]
fn should_suffix_scan(&self) -> bool
Returns true if the program is amenable to suffix scanning.
When this is true, as a heuristic, we assume it is OK to quickly scan for suffix literals and then do a reverse DFA match from any matches produced by the literal scan. (And then followed by a forward DFA search, since the previously found suffix literal maybe not actually be the end of a match.)
This is a bit of a specialized optimization, but can result in pretty big performance wins if 1) there are no prefix literals and 2) the suffix literals are pretty rare in the text. (1) is obviously easy to account for but (2) is harder. As a proxy, we assume that longer strings are generally rarer, so we only enable this optimization when we have a meaty suffix.
Trait Implementations
impl Debug for ExecReadOnly
[src]
impl Debug for ExecReadOnly
Auto Trait Implementations
impl Send for ExecReadOnly
impl Send for ExecReadOnly
impl Sync for ExecReadOnly
impl Sync for ExecReadOnly