3 ms·
curious, why is the compile-time regex slower? is it just a less efficient implementation?
by AYBABTME 11y ago
curious, why is the compile-time regex slower? is it just a less efficient implementation?
- killercup 11y agoYes, several of the optimizations of the dynamic regexes aren't available in the compile-time version. (It doesn't even have a DFA, IIRC.) There is [a lint][1] which checks that your regular expressions are valid (at compile time), though. [1]: https://github.com/Manishearth/rust-clippy/wiki#invalid_regex https://github.com/Manishearth/rust-clippy/wiki#invalid_rege...
- burntsushi 11y agoRegex::new has these tools at its disposal: Pike VM (NFA), backtracking (NFA), DFA (online), DFA (offline), Boyer-Moore The plugin has these tools at its disposal: Pike VM. But yeah, killercup is correct. The DFA (online) is one of the bigger reasons. But the offline DFA and Boyer-Moore are probably just as important. You might glean more information from my hacking guide: https://github.com/rust-lang-nursery/regex/blob/master/HACKING.md https://github.com/rust-lang-nursery/regex/blob/master/HACKI...