From: Eric Wong Date: Sat, 11 Jan 2020 22:34:55 +0000 (+0000) Subject: config: do not slurp entire cgitrc at once X-Git-Tag: v1.3.0~111 X-Git-Url: http://www.git.stargrave.org/?p=public-inbox.git;a=commitdiff_plain;h=7778d7abd5acb2ba7c32de10cec1369f3982bf84 config: do not slurp entire cgitrc at once cgitrc files can have hundreds or thousands of lines in them and slurping them into memory is a waste. "while (<$fh>)" only reads one line at a time, whereas "for (<$fh>)" reads the entire contents of the file into a temporary array. --- diff --git a/lib/PublicInbox/Config.pm b/lib/PublicInbox/Config.pm index 56d146c2..1ba1225e 100644 --- a/lib/PublicInbox/Config.pm +++ b/lib/PublicInbox/Config.pm @@ -249,7 +249,7 @@ sub scan_projects_coderepo ($$$) { warn "failed to open cgit projectlist=$list: $!\n"; return; }; - foreach (<$fh>) { + while (<$fh>) { chomp; scan_path_coderepo($self, $path, "$path/$_"); } @@ -274,7 +274,7 @@ sub parse_cgitrc { # FIXME: this doesn't support macro expansion via $VARS, yet my $repo; - foreach (<$fh>) { + while (<$fh>) { chomp; if (m!\Arepo\.url=(.+?)/*\z!) { my $nick = $1;