From 7778d7abd5acb2ba7c32de10cec1369f3982bf84 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 11 Jan 2020 22:34:55 +0000 Subject: 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. --- lib/PublicInbox/Config.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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; -- cgit v1.2.3-24-ge0c7