|We don't bite newbies here... much|
Re^4: Inexplicably slow regex (optimizer)by zigdon (Deacon)
|on Sep 13, 2006 at 19:36 UTC||Need Help??|
Hmm. Comparing the sol to nl (since they seem that they should behave very similarly) shows this in the re=debug dump:
And a typical match attempt looks like this:
Compare to the sol version:
Where a typical match attempt is more complex:
Unless I'm misreading it, it looks that the sol version has to rescan the string each time for a potential start point, and for the location of the 'x'. The nl version doesn't seem to need to redo all that work every round. My (wild) guess is that the ANYOF class that is implied by the '^/m' makes the engine think it cannot keep as much state between matches.
But this is really getting much deeper into the guts of perl than I'm really feeling comfortable guessing on.Maybe someone who's more familiar under the hood would be able to comment more?
As an aside, if you study $str before starting (takes a split second), the benchmark changes significantly, and seems much less insane: