]> Sergey Matveev's repositories - public-inbox.git/commitdiff
config: git_config_dump: pre-compile RE for split
authorEric Wong <e@80x24.org>
Wed, 23 Dec 2020 08:38:51 +0000 (08:38 +0000)
committerEric Wong <e@80x24.org>
Wed, 23 Dec 2020 23:46:43 +0000 (23:46 +0000)
It appears the Perl split() operator is not optimized for fixed
strings at all.  With this change, PublicInbox::Config->new (w/o
->fill_all) time is reduced from 1.81s to 1.22s on a config file
with 50K inboxes.

lib/PublicInbox/Config.pm

index cd8957a1276bb0fa01becd74bf47c61158aec127..4d143c6e3cc6620a920ec1ca30b463afe6df5e7d 100644 (file)
@@ -165,7 +165,7 @@ sub git_config_dump {
        return {} unless -e $file;
        my $cmd = [ qw(git config -z -l --includes), "--file=$file" ];
        my $fh = popen_rd($cmd);
-       my $rv = config_fh_parse($fh, "\0", "\n");
+       my $rv = config_fh_parse($fh, "\0", qr/\n/);
        close $fh or die "failed to close (@$cmd) pipe: $?";
        $rv;
 }