]> Sergey Matveev's repositories - public-inbox.git/commitdiff
feed: compile regexps only once
authorEric Wong <e@80x24.org>
Mon, 6 Jul 2015 21:22:22 +0000 (21:22 +0000)
committerEric Wong <e@80x24.org>
Mon, 6 Jul 2015 21:22:46 +0000 (21:22 +0000)
This avoids some runtime penalties associated with recompiling
a regexp based on a constant local variable.

lib/PublicInbox/Feed.pm

index dd9915324af33995205bb6509cb80dd08df75ff2..3c0ec86d4188d393f8cc734affb0dee5f86775bc 100644 (file)
@@ -168,14 +168,14 @@ sub each_recent_blob {
                        }
                } elsif ($line =~ /$delmsg/o) {
                        $deleted{$1} = 1;
-               } elsif ($line =~ /^commit (${hex}{7,40})/) {
+               } elsif ($line =~ /^commit (${hex}{7,40})/o) {
                        push @commits, $1;
                }
        }
 
        if ($last) {
                while (my $line = <$log>) {
-                       if ($line =~ /^commit (${hex}{7,40})/) {
+                       if ($line =~ /^commit (${hex}{7,40})/o) {
                                push @commits, $1;
                                last;
                        }