]> Sergey Matveev's repositories - public-inbox.git/commitdiff
viewvcs: switch to `print $zfh'
authorEric Wong <e@80x24.org>
Sat, 10 Sep 2022 08:17:29 +0000 (08:17 +0000)
committerEric Wong <e@80x24.org>
Sat, 10 Sep 2022 19:50:57 +0000 (19:50 +0000)
Again, ->zmore has proven expensive due to the overhead of
calling ->deflate on small strings, so print directly to the
file handle and let the PerlIO::scalar layer take care of
buffering.  One of the ->zmore calls was a no-op, even, so
drop that entirely.

lib/PublicInbox/ViewVCS.pm

index 57ab378d182098bb76fa106e7950c65033847558..f740591d1bd1a94d8b26ad05d5503e4169682627 100644 (file)
@@ -189,7 +189,8 @@ href="$f.patch">patch</a>)\n   <a href=#parent>parent</a> $P->[0]};
                $x = ' (<a href=#root_commit>root commit</a>)';
        }
        PublicInbox::WwwStream::html_init($ctx);
-       $ctx->zmore(<<EOM);
+       my $zfh = $ctx->zfh;
+       print $zfh <<EOM;
 <pre>   <a href=#commit>commit</a> $H$x
      <a href=#tree>tree</a> <a href="$upfx$T/s/">$T</a>
    author $au
@@ -197,16 +198,14 @@ committer $co
 
 <b>$s</b>
 EOM
-       $ctx->zmore("\n", $ctx->{-linkify}->to_html($bdy)) if length($bdy);
+       print $zfh "\n", $ctx->{-linkify}->to_html($bdy) if length($bdy);
        $bdy = '';
        open my $fh, '<:utf8', "$ctx->{-tmp}/p" or
                die "open $ctx->{-tmp}/p: $!";
        if (-s $fh > $MAX_SIZE) {
-               $ctx->zmore("---\n patch is too large to show\n");
+               print $zfh "---\n patch is too large to show\n";
        } else { # prepare flush_diff:
                read($fh, $x, -s _);
-               $ctx->zmore($bdy);
-               undef $bdy;
                $ctx->{-apfx} = $ctx->{-spfx} = $upfx;
                $x =~ s/\r?\n/\n/gs;
                $ctx->{-anchors} = {} if $x =~ /^diff --git /sm;
@@ -228,7 +227,7 @@ EOM
                        $q = wrap('', '', $q);
                        my $rows = ($q =~ tr/\n/\n/) + 1;
                        $q = ascii_html($q);
-                       $ctx->zmore(<<EOM);
+                       print $zfh <<EOM;
 <hr><form action=$upfx
 id=related><pre>find related emails, including ancestors/descendants/conflicts
 <textarea name=q cols=${\PublicInbox::View::COLS} rows=$rows>$q</textarea>