6 ms·
Could you have a heuristics based on the input size and the pattern to decide what to use?
by tracnar 6mo ago
Could you have a heuristics based on the input size and the pattern to decide what to use?
- ieviev 6mo agoYes, this is entirely possible. you can even explore the automaton eagerly and detect if it's possible to loop from an accepting state to a nonaccepting one. Exciting stuff for future work
- nextaccountic 6mo agoRipgrep does something like thhis. It has a meta regex engine that switches engine when it finds what looks like pathological cases (or rather, the regex-automata crate does, which is used by the regex crate, which powers ripgrep). https://docs.rs/regex-automata/latest/regex_automata/meta/struct.Regex.html#composition https://docs.rs/regex-automata/latest/regex_automata/meta/st... Ripgrep in turn exposes some knobs to tweak the heuristics https://github.com/BurntSushi/ripgrep/blob/master/FAQ.md#how-do-i-make-the--f--file-flag-faster https://github.com/BurntSushi/ripgrep/blob/master/FAQ.md#how...