diff options
author | Eric Wong <e@yhbt.net> | 2020-01-11 22:34:55 +0000 |
---|---|---|
committer | Eric Wong <e@yhbt.net> | 2020-01-13 04:36:36 +0000 |
commit | 7778d7abd5acb2ba7c32de10cec1369f3982bf84 (patch) | |
tree | 3131247fbea2919caba3afeae57954bb0d9722a3 | |
parent | ea5c81fb5c45d75528de81b91019af58782e2d91 (diff) | |
download | public-inbox-7778d7abd5acb2ba7c32de10cec1369f3982bf84.tar.gz |
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.
-rw-r--r-- | lib/PublicInbox/Config.pm | 4 |
1 files 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; |