From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id A76011F94D for ; Sun, 5 Jul 2020 23:28:14 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 35/43] view: /$INBOX/$MSGID/t/: avoid extra hash lookup in eml case Date: Sun, 5 Jul 2020 23:27:51 +0000 Message-Id: <20200705232759.3161-36-e@yhbt.net> In-Reply-To: <20200705232759.3161-1-e@yhbt.net> References: <20200705232759.3161-1-e@yhbt.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: We can build and buffer the HTML 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 | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm index 656953928..138e0c3a2 100644 --- a/lib/PublicInbox/View.pm +++ b/lib/PublicInbox/View.pm @@ -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