]> Sergey Matveev's repositories - public-inbox.git/commitdiff
config: do not slurp lines into memory
authorEric Wong <e@80x24.org>
Wed, 8 Feb 2017 21:41:38 +0000 (21:41 +0000)
committerEric Wong <e@80x24.org>
Thu, 9 Feb 2017 00:00:03 +0000 (00:00 +0000)
There's no need to hold everything in memory, here,
since apparently "foreach" will read everything at
once in array context

(for some reason, I thought Perl5 was smart enough
 to avoid creating a temporary array, here...)

lib/PublicInbox/Config.pm

index 28b5bdb5f895547909694f4c4916b9d7297f439e..f6275cdd24663d2f5b3f8235d7e188a04863b923 100644 (file)
@@ -111,7 +111,7 @@ sub git_config_dump {
        my $fh = popen_rd(\@cmd) or die "popen_rd failed for $file: $!\n";
        my %rv;
        local $/ = "\n";
        my $fh = popen_rd(\@cmd) or die "popen_rd failed for $file: $!\n";
        my %rv;
        local $/ = "\n";
-       foreach my $line (<$fh>) {
+       while (defined(my $line = <$fh>)) {
                chomp $line;
                my ($k, $v) = split(/=/, $line, 2);
                my $cur = $rv{$k};
                chomp $line;
                my ($k, $v) = split(/=/, $line, 2);
                my $cur = $rv{$k};