in reply to RE: RE: RE: Regular Expression Optimizer
in thread Regular Expression Optimizer
First of all are we including compilation time in the performance? A DFA can be implemented with a complex analysis up front, but faster runtime, or by doing a simple analysis up front, and then interpret a bitmap of states at the end.
The first can result in a compiled RE that is exponential in the size of the expression. The second cannot blow up at compile time that way, but the size of the RE definitely affects the runtime performance.
In the real world, either can wind up being faster.
Going beyond that, any smart RE engine (it would be safe to assume that Perl's is smart) can take advantage of the fact that long fixed substrings can be located and matched *faster* than you can scan a string. An RE engine that is able to notice then use such optimizations is very nice to have - and this is one of the reasons that simple Perl scripts can wind up beating custom C programs at text processing!
(I would wonder if this is an example of a "non-algorithmic" improvement. :-)
|
|---|