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:50 +0000
committerEric Wong <e@yhbt.net>2020-07-06 20:01:15 +0000
commitbf8ea90e0db55666e558893bf00b703ddd211d45 (patch)
tree5c5290da9090a5a354aad1d9d513d5f384e2279d /lib/PublicInbox/View.pm
parent7845a9dd163b67e8a03533aee17a74265dc9e14f (diff)
downloadpublic-inbox-bf8ea90e0db55666e558893bf00b703ddd211d45.tar.gz
We can save stack space and simplify subroutine calls, here.
Diffstat (limited to 'lib/PublicInbox/View.pm')
-rw-r--r--lib/PublicInbox/View.pm17
1 files changed, 9 insertions, 8 deletions
diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index 16a0fcdf..65695392 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -181,7 +181,8 @@ sub fmt_ts ($) { strftime('%Y-%m-%d %k:%M', gmtime($_[0])) }
 # Displays the text of of the message for /$INBOX/$MSGID/[Tt]/ endpoint
 # this is already inside a <pre>
 sub eml_entry {
-        my ($ctx, $smsg, $eml, $more) = @_;
+        my ($ctx, $eml, $more) = @_;
+        my $smsg = delete $ctx->{smsg};
         my $subj = delete $smsg->{subject};
         my $mid_raw = $smsg->{mid};
         my $id = id_compress($mid_raw, 1);
@@ -370,9 +371,9 @@ sub pre_thread  { # walk_thread callback
 }
 
 sub thread_eml_entry {
-        my ($ctx, $level, $smsg, $eml) = @_;
-        my ($beg, $end) = thread_adj_level($ctx, $level);
-        $beg . '<pre>' . eml_entry($ctx, $smsg, $eml, 0) . '</pre>' . $end;
+        my ($ctx, $eml) = @_;
+        my ($beg, $end) = thread_adj_level($ctx, $ctx->{level});
+        $beg . '<pre>' . eml_entry($ctx, $eml, 0) . '</pre>' . $end;
 }
 
 sub next_in_queue ($$) {
@@ -390,12 +391,12 @@ sub stream_thread_i { # PublicInbox::WwwStream::getline callback
         my ($ctx, $eml) = @_;
 
         if ($eml) {
-                my ($level, $smsg) = delete @$ctx{qw(level smsg)};
                 if ($ctx->{nr} == 1) {
-                        $ctx->{-title_html} = ascii_html($smsg->{subject});
+                        $ctx->{-title_html} =
+                                        ascii_html($ctx->{smsg}->{subject});
                         $ctx->zmore($ctx->html_top);
                 }
-                return thread_eml_entry($ctx, $level, $smsg, $eml);
+                goto &thread_eml_entry; # tail recursion
         }
         return unless exists($ctx->{skel});
         my $ghost_ok = $ctx->{nr}++;
@@ -470,7 +471,7 @@ sub thread_html_i { # PublicInbox::WwwStream::getline callback
                         $ctx->{-title_html} = ascii_html($smsg->{subject});
                         $ctx->zmore($ctx->html_top);
                 }
-                return eml_entry($ctx, $smsg, $eml, scalar @{$ctx->{msgs}});
+                return eml_entry($ctx, $eml, scalar @{$ctx->{msgs}});
         } else {
                 while (my $smsg = shift @{$ctx->{msgs}}) {
                         return $smsg if exists($smsg->{blob});