3 ms·
Almost every knows that supporting backrefs makes it slow, i.e. exponential. I'm tired of these excuses which come up all the time. What is perl5's solution to
by rurban 11y ago
Almost every knows that supporting backrefs makes it slow, i.e. exponential. I'm tired of these excuses which come up all the time.
What is perl5's solution to this problem? Saying that is unsolvable (like here), and supporting external matchers. Nobody uses them because it's a joke.
What it should of course do is to check for abnormal backrefs and use a fast matcher without backrefs. 90% of the regexes have no backrefs.
There would be a tiny performance problem if perl5 would use a normal dynamic one-pass compilation, something a modern matcher does. But it uses old-style two-pass compilation, so it's trivial to check if there's a backref, and use a proper Thompson NFA if not. Or a faster jitted variant. Instead p5p still holds on to their awful Spencer DFA with longjmp's all over the place to fix the broken architecture, and engages heavily in badmouthing better algorithms and implementations.
The few changes that were done there made it even slower. Davem's conversion from recursion to iteration caused a significant performance bump. Davem's support for proper /e (eval rhs expressions) caused another significant performance bump.
You are not allowed to critize that. The p5p zealots will come all over you. Ross Cox ran away very fast.