From 433f6127f648e83b8f12d7b232ff726a34a85beb Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 21 Mar 2020 02:03:46 +0000 Subject: wwwstream: introduce oneshot API to avoid ->getline The ->getline API is only useful for limiting memory use when streaming responses containing multiple emails or log messages. However it's unnecessary complexity and overhead for callers (PublicInbox::HTTP) when there's only a single message. --- lib/PublicInbox/ViewVCS.pm | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'lib/PublicInbox/ViewVCS.pm') diff --git a/lib/PublicInbox/ViewVCS.pm b/lib/PublicInbox/ViewVCS.pm index 2f8e1c4f..6714e67c 100644 --- a/lib/PublicInbox/ViewVCS.pm +++ b/lib/PublicInbox/ViewVCS.pm @@ -31,17 +31,11 @@ my %QP_MAP = ( A => 'oid_a', B => 'oid_b', a => 'path_a', b => 'path_b' ); our $MAX_SIZE = 1024 * 1024; # TODO: configurable my $BIN_DETECT = 8000; # same as git -sub html_i { # WwwStream::getline callback - my ($nr, $ctx) = @_; - $nr == 1 ? ${delete $ctx->{obuf}} : undef; -} - sub html_page ($$$) { my ($ctx, $code, $strref) = @_; my $wcb = delete $ctx->{-wcb}; $ctx->{-upfx} = '../../'; # from "/$INBOX/$OID/s/" - $ctx->{obuf} = $strref; - my $res = PublicInbox::WwwStream->response($ctx, $code, \&html_i); + my $res = PublicInbox::WwwStream::oneshot($ctx, $code, $strref); $wcb ? $wcb->($res) : $res; } -- cgit v1.2.3-24-ge0c7