diff options
author | Eric Wong <e@80x24.org> | 2019-12-25 07:50:58 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2019-12-27 20:00:37 +0000 |
commit | 2d2b53538f1121e98ddc0652e2749bb90ea97769 (patch) | |
tree | a592a93537620e838cb9ae170456feb0f20878b2 /lib/PublicInbox | |
parent | 15b14846a2fceff10d409bd1fd6d9a73a841df97 (diff) | |
download | public-inbox-2d2b53538f1121e98ddc0652e2749bb90ea97769.tar.gz |
We can pass everything we need into the WWW $ctx to avoid allocating kilobytes of memory for an anonymous sub for every $MESSAGE_ID/t/ request.
Diffstat (limited to 'lib/PublicInbox')
-rw-r--r-- | lib/PublicInbox/View.pm | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm index 1e2d3b55..5c64441a 100644 --- a/lib/PublicInbox/View.pm +++ b/lib/PublicInbox/View.pm @@ -484,17 +484,19 @@ sub thread_html { return missing_thread($ctx) unless $smsg; $ctx->{-title_html} = ascii_html($smsg->subject); $ctx->{-html_tip} = '<pre>'.index_entry($smsg, $ctx, scalar @$msgs); - $smsg = undef; - PublicInbox::WwwStream->response($ctx, 200, sub { - return unless $msgs; - $smsg = undef; - while (my $m = shift @$msgs) { - $smsg = $ibx->smsg_mime($m) and last; - } - return index_entry($smsg, $ctx, scalar @$msgs) if $smsg; - $msgs = undef; - $skel; - }); + $ctx->{msgs} = $msgs; + PublicInbox::WwwStream->response($ctx, 200, \&thread_html_i); +} + +sub thread_html_i { # PublicInbox::WwwStream::getline callback + my ($nr, $ctx) = @_; + my $msgs = $ctx->{msgs} or return; + while (my $smsg = shift @$msgs) { + $ctx->{-inbox}->smsg_mime($smsg) or next; + return index_entry($smsg, $ctx, scalar @$msgs); + } + my ($skel) = delete @$ctx{qw(dst msgs)}; + $$skel; } sub multipart_text_as_html { |