]> Sergey Matveev's repositories - public-inbox.git/commitdiff
config: do not slurp entire cgitrc at once
authorEric Wong <e@yhbt.net>
Sat, 11 Jan 2020 22:34:55 +0000 (22:34 +0000)
committerEric Wong <e@yhbt.net>
Mon, 13 Jan 2020 04:36:36 +0000 (04:36 +0000)
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

index 56d146c2292f4cf83bc53936ffe4dffcb41e1dd4..1ba1225e9085a8305268c2d004ac45f120a94ec3 100644 (file)
@@ -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;