]> Sergey Matveev's repositories - public-inbox.git/commitdiff
view: /$INBOX/$MSGID/t/: avoid extra hash lookup in eml case
authorEric Wong <e@yhbt.net>
Sun, 5 Jul 2020 23:27:51 +0000 (23:27 +0000)
committerEric Wong <e@yhbt.net>
Mon, 6 Jul 2020 20:01:15 +0000 (20:01 +0000)
We can build and buffer the HTML <head> section once the first
non-ghost message in a thread is loaded, so there's no need to
perform an extra check on $ctx->{nr} once the $eml is ready.

lib/PublicInbox/View.pm

index 65695392817990f0748d8a560f567776d3b42a5f..138e0c3a217d6173de7049c577fcc0ea72769594 100644 (file)
@@ -389,15 +389,7 @@ sub next_in_queue ($$) {
 
 sub stream_thread_i { # PublicInbox::WwwStream::getline callback
        my ($ctx, $eml) = @_;
-
-       if ($eml) {
-               if ($ctx->{nr} == 1) {
-                       $ctx->{-title_html} =
-                                       ascii_html($ctx->{smsg}->{subject});
-                       $ctx->zmore($ctx->html_top);
-               }
-               goto &thread_eml_entry; # tail recursion
-       }
+       goto &thread_eml_entry if $eml; # tail recursion
        return unless exists($ctx->{skel});
        my $ghost_ok = $ctx->{nr}++;
        while (1) {
@@ -405,6 +397,11 @@ sub stream_thread_i { # PublicInbox::WwwStream::getline callback
                if ($smsg) {
                        if (exists $smsg->{blob}) { # next message for cat-file
                                $ctx->{level} = $lvl;
+                               if (!$ghost_ok) { # first non-ghost
+                                       $ctx->{-title_html} =
+                                               ascii_html($smsg->{subject});
+                                       $ctx->zmore($ctx->html_top);
+                               }
                                return $smsg;
                        }
                        # buffer the ghost entry and loop