about summary refs log tree commit homepage
path: root/lib/PublicInbox/View.pm
diff options
context:
space:
mode:
authorEric Wong <e@yhbt.net>2020-07-05 23:27:46 +0000
committerEric Wong <e@yhbt.net>2020-07-06 20:01:15 +0000
commit677772ba8f661e78494ee1d185ab05ad5bdaac87 (patch)
treea48b941ddcc027bec616f99a1c8df8573328b749 /lib/PublicInbox/View.pm
parent8d3f4751eacbad29e24da26aafacfe9b6bad22a3 (diff)
downloadpublic-inbox-677772ba8f661e78494ee1d185ab05ad5bdaac87.tar.gz
Another 10% or so speedup in a frequently-hit endpoint.
Diffstat (limited to 'lib/PublicInbox/View.pm')
-rw-r--r--lib/PublicInbox/View.pm23
1 files changed, 13 insertions, 10 deletions
diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index 117257a6..16a0fcdf 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -459,23 +459,26 @@ sub thread_html {
         # flat display: lazy load the full message from smsg
         $ctx->{msgs} = $msgs;
         $ctx->{-html_tip} = '<pre>';
-        PublicInbox::WwwStream::response($ctx, 200, \&thread_html_i);
+        PublicInbox::WwwStream::aresponse($ctx, 200, \&thread_html_i);
 }
 
 sub thread_html_i { # PublicInbox::WwwStream::getline callback
-        my ($ctx) = @_;
-        my $msgs = $ctx->{msgs} or return;
-        while (my $smsg = shift @$msgs) {
-                my $eml = $ctx->{-inbox}->smsg_eml($smsg) or next;
+        my ($ctx, $eml) = @_;
+        if ($eml) {
+                my $smsg = $ctx->{smsg};
                 if (exists $ctx->{-html_tip}) {
                         $ctx->{-title_html} = ascii_html($smsg->{subject});
-                        return $ctx->html_top .
-                                eml_entry($ctx, $smsg, $eml, scalar @$msgs);
+                        $ctx->zmore($ctx->html_top);
+                }
+                return eml_entry($ctx, $smsg, $eml, scalar @{$ctx->{msgs}});
+        } else {
+                while (my $smsg = shift @{$ctx->{msgs}}) {
+                        return $smsg if exists($smsg->{blob});
                 }
-                return eml_entry($ctx, $smsg, $eml, scalar @$msgs);
+                my $skel = delete($ctx->{skel}) or return; # all done
+                $ctx->zmore($$skel);
+                undef;
         }
-        my ($skel) = delete @$ctx{qw(skel msgs)};
-        $$skel;
 }
 
 sub multipart_text_as_html {