Efficiency: use $1 (first group in parentheses) instead of $& (entire 
matched, which has a performance impact).  Add parentheses where necessary.

        Efficiency: use $1 (first group in parentheses) instead of $& (entire 
matched, which has a performance impact). 

diffs (135 lines):

diff -r 14f68f3391dc -r e1436432dc4f cgi-bin/Apache/LiveJournal.pm
--- a/cgi-bin/Apache/LiveJournal.pm     Wed Dec 01 11:19:22 2010 +0800
+++ b/cgi-bin/Apache/LiveJournal.pm     Wed Dec 01 11:40:22 2010 +0800
@@ -287,7 +287,7 @@ sub trans
     my $args = $r->args;
     my $args_wq = $args ? "?$args" : "";
     my $host = $r->headers_in->{"Host"};
-    my $hostport = ( $host =~ s/:\d+$// ) ? $& : "";
+    my $hostport = ( $host =~ s/(:\d+)$// ) ? $1 : "";
 
     # Allow hosts ending in . to work properly.
     $host =~ s/\.$//;
diff -r 14f68f3391dc -r e1436432dc4f cgi-bin/LJ/CleanHTML.pm
--- a/cgi-bin/LJ/CleanHTML.pm   Wed Dec 01 11:19:22 2010 +0800
+++ b/cgi-bin/LJ/CleanHTML.pm   Wed Dec 01 11:40:22 2010 +0800
@@ -1046,7 +1046,7 @@ sub clean
                         return "&url$urlcount;$str&urlend;";
                     }
                 };
-                $token->[1] =~ s!https?://[^\s\'\"\<\>]+[a-zA-Z0-9_/&=\-]! 
$match->($&); !ge;
+                $token->[1] =~ s!(https?://[^\s\'\"\<\>]+[a-zA-Z0-9_/&=\-])! 
$match->( $1 ); !ge;
             }
 
             # escape tags in text tokens.  shouldn't belong here!
@@ -1057,7 +1057,7 @@ sub clean
 
             # put <wbr> tags into long words, except inside <pre> and 
<textarea>.
             if ($wordlength && !$opencount{'pre'} && !$opencount{'textarea'}) {
-                $token->[1] =~ 
s/\S{$wordlength,}/break_word($&,$wordlength)/eg;
+                $token->[1] =~ s/(\S{$wordlength,})/break_word( $1, 
$wordlength )/eg;
             }
 
             # auto-format things, unless we're in a textarea, when it doesn't 
make sense
@@ -1381,7 +1381,7 @@ sub clean_event
 
     # fast path:  no markup or URLs to linkify, and no suspend message needed
     if ($$ref !~ /\<|\>|http/ && ! $opts->{preformatted} && 
!$opts->{suspend_msg}) {
-        $$ref =~ s/\S{$wordlength,}/break_word($&,$wordlength)/eg if 
$wordlength;
+        $$ref =~ s/(\S{$wordlength,})/break_word( $1, $wordlength )/eg if 
$wordlength;
         $$ref =~ s/\r?\n/<br \/>/g;
         return;
     }
@@ -1443,7 +1443,7 @@ sub clean_comment
 
     # fast path:  no markup or URLs to linkify
     if ($$ref !~ /\<|\>|http/ && ! $opts->{preformatted}) {
-        $$ref =~ s/\S{40,}/break_word($&,40)/eg;
+        $$ref =~ s/(\S{40,})/break_word( $1, 40 )/eg;
         $$ref =~ s/\r?\n/<br \/>/g;
         return 0;
     }
diff -r 14f68f3391dc -r e1436432dc4f cgi-bin/LJ/SynSuck.pm
--- a/cgi-bin/LJ/SynSuck.pm     Wed Dec 01 11:19:22 2010 +0800
+++ b/cgi-bin/LJ/SynSuck.pm     Wed Dec 01 11:40:22 2010 +0800
@@ -142,7 +142,7 @@ sub process_content {
     # XML::Parser doesn't include Windows-1252, but we put it in cgi-bin/XML/* 
for it
     # to find.
     my $encoding;
-    if ($content =~ /<\?xml.+?>/ && $& =~ /encoding=([\"\'])(.+?)\1/) {
+    if ( $content =~ /(<\?xml.+?>)/ && $1 =~ /encoding=([\"\'])(.+?)\1/ ) {
         $encoding = lc($2);
     }
     if (! $encoding && ! LJ::is_utf8($content)) {
diff -r 14f68f3391dc -r e1436432dc4f cgi-bin/LJ/Talk.pm
--- a/cgi-bin/LJ/Talk.pm        Wed Dec 01 11:19:22 2010 +0800
+++ b/cgi-bin/LJ/Talk.pm        Wed Dec 01 11:40:22 2010 +0800
@@ -3199,9 +3199,9 @@ sub init {
         if ($form->{'userpost'}) {
 
             # parse inline login opts
-            if ($form->{'userpost'} =~ s/[!<]{1,2}$//) {
-                $exptype = 'long' if index($&, "!") >= 0;
-                $ipfixed = LJ::get_remote_ip() if index($&, "<") >= 0;
+            if ( $form->{userpost} =~ s/([!<]{1,2})$// ) {
+                $exptype = 'long' if index( $1, "!" ) >= 0;
+                $ipfixed = LJ::get_remote_ip() if index( $1, "<" ) >= 0;
             }
 
             $up = LJ::load_user($form->{'userpost'});
@@ -3285,12 +3285,12 @@ sub init {
 
             # parse inline login opts
             return $err->("No OpenID identity URL entered") unless 
$form->{'oidurl'};
-            if ($form->{'oidurl'} =~ s/[!<]{1,2}$//) {
-                if (index($&, "!") >= 0) {
+            if ( $form->{oidurl} =~ s/([!<]{1,2})$// ) {
+                if ( index( $1, "!" ) >= 0 ) {
                     $exptype = 'long';
                     $etime = time()+60*60*24*60;
                 }
-                $ipfixed = LJ::get_remote_ip() if index($&, "<") >= 0;
+                $ipfixed = LJ::get_remote_ip() if index( $1, "<" ) >= 0;
             }
 
             my $tried_local_ref = LJ::OpenID::blocked_hosts($csr);
diff -r 14f68f3391dc -r e1436432dc4f cgi-bin/weblib.pl
--- a/cgi-bin/weblib.pl Wed Dec 01 11:19:22 2010 +0800
+++ b/cgi-bin/weblib.pl Wed Dec 01 11:40:22 2010 +0800
@@ -129,7 +129,7 @@ sub auto_linkify
             return "<a href='$str'>$str</a>";
         }
     };
-    $str =~ s!https?://[^\s\'\"\<\>]+[a-zA-Z0-9_/&=\-]! $match->($&); !ge
+    $str =~ s!(https?://[^\s\'\"\<\>]+[a-zA-Z0-9_/&=\-])! $match->( $1 ); !ge
         if defined $str;
 
     return $str;
diff -r 14f68f3391dc -r e1436432dc4f htdocs/login.bml
--- a/htdocs/login.bml  Wed Dec 01 11:19:22 2010 +0800
+++ b/htdocs/login.bml  Wed Dec 01 11:40:22 2010 +0800
@@ -26,9 +26,9 @@ _c?>
 
     # ! after username overrides expire to never
     # < after username overrides ipfixed to yes
-    if ($POST{'user'} =~ s/[!<]{1,2}$//) {
-        $POST{'expire'} = 'never' if index($&, "!") >= 0;
-        $POST{'bindip'} = 'yes' if index($&, "<") >= 0;
+    if ( $POST{user} =~ s/([!<]{1,2})$// ) {
+        $POST{expire} = 'never' if index( $1, "!" ) >= 0;
+        $POST{bindip} = 'yes' if index( $1, "<" ) >= 0;
     }
 
     my $user = LJ::canonical_username($POST{'user'});
diff -r 14f68f3391dc -r e1436432dc4f htdocs/support/faqsearch.bml
--- a/htdocs/support/faqsearch.bml      Wed Dec 01 11:19:22 2010 +0800
+++ b/htdocs/support/faqsearch.bml      Wed Dec 01 11:40:22 2010 +0800
@@ -103,7 +103,7 @@ _c?>
     $body .= "<ul class='spaced'>";
     foreach my $f (@results) {
        my $dq = $f->question_html;
-       $dq =~ s/\Q$q\E/$term->($&)/ige;
+       $dq =~ s/(\Q$q\E)/$term->( $1 )/ige;
        my $ueq = LJ::eurl($q);
         my $ul = $GET{'lang'} ne $curr ? "&amp;lang=".$GET{'lang'} : '';
 
_______________________________________________
dw-changelog mailing list
[email protected]
http://lists.dwscoalition.org/mailman/listinfo/dw-changelog

Reply via email to