PSA: regex got a lazy DFA. it's fast. report problems!


#1

PR: https://github.com/rust-lang-nursery/regex/pull/164

This was a substantial change with no changes in the public API, so you’ll automatically get it on the next cargo update. Please be vigilant for any problems and report them so they can get fixed. :slight_smile:

There are benchmarks on the PR. Highlights:

  1. We’re faster that PCRE in many of the benchmarks. Still some room for improvements.
  2. Don’t use the regex! macro. It’s incredibly slower on almost every dimension. (We’re talking multiple orders of magnitude here.) It’s so bad that there is talk of removing it altogether until the approach can be revisited. Thoughts?
  3. I wrote a high level design overview of the library: HACKING.md. Feedback welcome!

#2

Couldn’t we change the regex macro to validate the syntax at compile time but then expand to Regex::new(..).unwrap()? Just having the syntax checked at compile time seems worth it.


#3

Well, I guess clippy does that now for Regex::new, which is nice. That also would mean that it couldn’t be used in static, although I guess we could inline lazy_static! into the plugin to make that work.

But yeah, this is the kind of decision that needs to be made, and I think it requires nailing down the design goals of regex!. For example, one such goal might be, “never heap allocate,” which might be useful in certain contexts, but also of course makes the implementation rather challenging!