]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
repobrowse: avoid slurping lines
authorEric Wong <e@80x24.org>
Thu, 9 Feb 2017 00:26:52 +0000 (00:26 +0000)
committerEric Wong <e@80x24.org>
Thu, 9 Feb 2017 00:41:39 +0000 (00:41 +0000)
"foreach (<$fh>)" in Perl requests lines in array
context, so use "while" instead for lazy reading.

This follows ba4c50c20b95679580beba1ef290a4281d5285b7
in master ("config: do not slurp lines into memory")

lib/PublicInbox/RepobrowseBase.pm
lib/PublicInbox/RepobrowseGitSummary.pm

index caec5ced6da3db39a7a1fd985697168d20bcf4c3..44f422df3e09b375ef168899b677fc845cfa5052 100644 (file)
@@ -24,7 +24,7 @@ sub mime_load {
        my ($self, $file) = @_;
        my %rv;
        open my $fh, '<', $file or return \%rv;
-       foreach (<$fh>) {
+       while (<$fh>) {
                next if /^#/; # no comments
                my ($type, @ext) = split(/\s+/);
 
index b6b960289644dd59375b7e6e9ff7a6d70d89f9bd..e7739ecdee905af5ee1961015dff409d63f7f9e9 100644 (file)
@@ -48,7 +48,7 @@ sub for_each_ref {
                        '</pre><table>');
 
        my $rel = $req->{relcmd};
-       foreach (<$refs>) {
+       while (<$refs>) {
                my ($ref, $type, $hex, $date, $s) = split(' ', $_, 5);
                my $x = $ref eq $head_ref ? ' (HEAD)' : '';
                $ref =~ s!\Arefs/(?:heads|tags)/!!;