]> Sergey Matveev's repositories - public-inbox.git/commitdiff
viewvcs: use shorter and simpler ctx->html_done
authorEric Wong <e@80x24.org>
Sat, 10 Sep 2022 08:16:58 +0000 (08:16 +0000)
committerEric Wong <e@80x24.org>
Sat, 10 Sep 2022 19:50:29 +0000 (19:50 +0000)
We only return 200s for any response large enough to warrant
->html_done, so we can just assume it.  ViewVCS can also take
advantage of it with some tweaking to avoid an extra method
dispatch.

lib/PublicInbox/View.pm
lib/PublicInbox/ViewVCS.pm
lib/PublicInbox/WwwStream.pm

index 1cbc62bee5f29f7280d83b2a332a34d19eeb6a06..c6fd05cce3a59e8327c4959db3f7480ff759b0b7 100644 (file)
@@ -61,7 +61,7 @@ sub no_over_html ($) {
                ${$ctx->{obuf}} .= '</pre><hr>';
        }
        html_footer($ctx, $eml);
-       $ctx->html_done(200);
+       $ctx->html_done;
 }
 
 # public functions: (unstable)
index ed4a645451176be47a38d9ccaa359907f114034f..d3ac1a7d5d111e40a8c32babcfe81eac312370b9 100644 (file)
@@ -253,10 +253,7 @@ possible to have multiple root commits when merging independent histories.
 
 Every commit references one top-level <dfn id=tree>tree</dfn> object.</pre>
 EOM
-       $x = $ctx->zflush($x, $ctx->_html_end);
-       my $res_hdr = delete $ctx->{-res_hdr};
-       push @$res_hdr, 'Content-Length', length($x);
-       delete($ctx->{env}->{'qspawn.wcb'})->([200, $res_hdr, [$x]]);
+       delete($ctx->{env}->{'qspawn.wcb'})->($ctx->html_done($x));
 }
 
 sub stream_patch_parse_hdr { # {parse_hdr} for Qspawn
index 1fc213d45f6b0457697ef1d7596e66b91e0d066b..c23668a440bbcfe12c4eee3d7ffb52533c21ae1a 100644 (file)
@@ -167,12 +167,12 @@ sub getline {
        $ctx->zflush(_html_end($ctx));
 }
 
-sub html_done ($$) {
-       my ($ctx, $code) = @_;
-       my $bdy = $ctx->zflush(_html_end($ctx));
+sub html_done ($;@) {
+       my $ctx = $_[0];
+       my $bdy = $ctx->zflush(@_[1..$#_], _html_end($ctx));
        my $res_hdr = delete $ctx->{-res_hdr};
        push @$res_hdr, 'Content-Length', length($bdy);
-       [ $code, $res_hdr, [ $bdy ] ]
+       [ 200, $res_hdr, [ $bdy ] ]
 }
 
 sub html_oneshot ($$;@) {