develooper Front page | perl.perl5.porters | Postings from March 2007

Re: $& in diagnostics.pm

Thread Previous | Thread Next
From:
Rafael Garcia-Suarez
Date:
March 15, 2007 09:33
Subject:
Re: $& in diagnostics.pm
Message ID:
b77c1dce0703150933k705d149agf1c2260c8115079a@mail.gmail.com
On 15/03/07, Andy Lester <andy@petdance.com> wrote:
>
> Surprising problem of the day: We set up our test bot to run with -
> Mdiagnostics, and performance went in the toilet, and some of our
> tests that make sure indexing happens within a reasonable amount of
> time actually failed.
>
> Why?  because diagnostics.pm uses $& and $', which makes all our
> regex-based code go sloooow, especially KinoSearch.

Apparently only $&, and only once, in blead at least.

> Anyone feel like modifying diagnostics.pm to remove those?  It seems
> like the Right Thing To Do.  Otherwise, I will and submit a patch
> tomorrow or next week.

Ooh look a real-world test for a blead feature.

Could you try this ?

==== //depot/perl/lib/diagnostics.pm#41 -
/home/rafael/p4blead/lib/diagnostics.pm ====
--- /tmp/tmp.22268.66   2007-03-15 17:32:24.000000000 +0100
+++ /home/rafael/p4blead/lib/diagnostics.pm     2007-03-15
17:31:13.000000000 +0100
@@ -394,7 +394,7 @@ my %msg;
                         $toks[$i] = '[\da-f]+';
                    }
                 } elsif( length( $toks[$i] ) ){
-                    $toks[$i] =~ s/^.*$/\Q$&\E/;
+                    $toks[$i] =~ s/^.*$/\Q${^MATCH}\E/p;
                     $conlen += length( $toks[$i] );
                 }
             }

(The backwards-compatible equivalent is left as an exercise to the reader...)

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About