From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.0 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 3B6141FAF4 for ; Thu, 9 Feb 2017 00:27:12 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH] config: do not slurp lines into memory Date: Thu, 9 Feb 2017 00:27:12 +0000 Message-Id: <20170209002712.24300-1-e@80x24.org> List-Id: 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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/PublicInbox/Config.pm b/lib/PublicInbox/Config.pm index 28b5bdb..f6275cd 100644 --- a/lib/PublicInbox/Config.pm +++ b/lib/PublicInbox/Config.pm @@ -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"; - foreach my $line (<$fh>) { + while (defined(my $line = <$fh>)) { chomp $line; my ($k, $v) = split(/=/, $line, 2); my $cur = $rv{$k}; -- EW