diff options
Diffstat (limited to 'src/regex/dfa.rs')
| -rw-r--r-- | src/regex/dfa.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/regex/dfa.rs b/src/regex/dfa.rs index c55d99d..78a216c 100644 --- a/src/regex/dfa.rs +++ b/src/regex/dfa.rs @@ -374,6 +374,15 @@ impl DFA { pub fn minify(&mut self) { for state in self.states.iter_mut() { state.trans.retain(|_, to| *to != state.default_trans); + if state.trans.len() == 1 + && state + .trans + .iter() + .all(|t| *t.0 == ByteRange::new_range(0, 255)) + { + state.default_trans = state.trans.iter().map(|x| *x.1).next().unwrap(); + state.trans.clear(); + } } self.hopcroft_minimization(); |
