New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
regexp optimizer loses its hopes too soon #8440
Comments
From rvtol+perlbug@isolution.nlCreated by rvtol+perlbug@isolution.nlI compared perl -le '("z"x55) =~ /^(.{0,10}){1,5}(?{$count++})$/m; to perl -le '("z"x55) =~ /(?m-xis:^(.{0,10}){1,5}(?{$count++})$)/; and to perl -le '("z"x55) =~ /(?m-xis)^(.{0,10}){1,5}(?{$count++})$/; and found that the first and the last variant return quickly (without Perl Info
|
From @druud62'intuit' is not activated with /(?m:^...$)/ regexp-format? [1] perl -Mre=debug -e '"zzz" =~ /^.{1,2}$/m' Freeing REx: `","' [2] perl -Mre=debug -e '"zzz" =~ /(?m:^.{1,2}$)/' Freeing REx: `","' |
The RT System itself - Status changed from 'new' to 'open' |
From dland@landgren.netIn the two instances that match quickly, the optimser rejects the first An alternative is to use \a and \z assertions instead, which are immune perl -le '("z"x55) =~ /(?m-xis:\a(.{0,10}){1,5}(?{$count++})\z)/; David |
From @iabynOn Sun, May 07, 2006 at 02:07:10AM -0700, rvtol+perlbug @ isolution. nl wrote:
Thnaks for the report. The second case is in fact the expected behaviour; Ideally the optimiser should be extended to note this case too, although i -- |
From @druud62Dave Mitchell schreef:
But AFAIK, a 1-to-1 mapping exists between these 3 regexps, so they mean
Maybe a unifying step (for at least the modifiers) is feasible? -- "Gewoon is een tijger." |
From mjtg@cam.ac.uk"Dr.Ruud" <rvtol+news@isolution.nl> wrote
They can't be straightforwardly unified because of the capturing parens. Mike Guy |
From @druud62Mike Guy schreef:
Care to explain? I see the same thing in all three. The difference stays the same when non-capturing: ("z"x65) =~ $_ for Again, the optimizer only gets the first and third one. Amazingly: print "$_\n" for (?mx-is: ^ (?:.{0,10}) {1,6} (?{$count++}) $ ) That variant of the second also returns quickly. And that seems to only $ perl -Mre=debug -e '("z"x65) =~ /(?-xism:(?mx-is: ^ (?:.{0,10}) {1,6} Compiling REx `(?-xism:(?mx-is: ^ (?:.{0,10}) {1,6} (?{$count++}) $) )' -- "Gewoon is een tijger." |
From @demerphqOn Fri May 19 16:33:49 2006, rvtol+news@isolution.nl wrote:
Be careful that should read ("z"x65) =~ $_ for Otherwise the second one tries to look for a space.
This is the important part.
What seems to be happening is that the optimiser is over-pessimising /foo+(?m:blah$)\nblah$/ At least thats how i understand it. So while /(?msix:...)/ affects what I know what to change to make it so that /(?m:....)/ is changed to be the same as /(?m)/ but i dont know what do about other cases, such as /(?m:....)(?m:.....)/ And I also have no idea why ("z"x65) =~ qr/^ (?:.{0,10}){1,6} (?{$count++}) $/mx is efficient (ie the optimiser rejects the match outright) But ('z'x65) =~ qr/^ (?:.{0,10}){1,6} (?{$count++}) $/x is not. I would have thought the latter could be rejected outright, i Ideas on how to procede welcome. Cheers, |
@demerphq - Status changed from 'open' to 'stalled' |
Migrated from rt.perl.org#39096 (status was 'stalled')
Searchable as RT39096$
The text was updated successfully, but these errors were encountered: