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 785A91F94C for ; Sun, 5 Jul 2020 23:28:14 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 34/43] view: eml_entry: reduce parameters Date: Sun, 5 Jul 2020 23:27:50 +0000 Message-Id: <20200705232759.3161-35-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 save stack space and simplify subroutine calls, here. --- Documentation/mknews.perl | 4 ++-- lib/PublicInbox/Feed.pm | 2 +- lib/PublicInbox/SearchView.pm | 2 +- lib/PublicInbox/View.pm | 17 +++++++++-------- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/Documentation/mknews.perl b/Documentation/mknews.perl index 51d54b716..4a5d0e563 100755 --- a/Documentation/mknews.perl +++ b/Documentation/mknews.perl @@ -103,9 +103,9 @@ sub mime2txt { sub mime2html { my ($out, $eml, $ctx) = @_; - my $smsg = bless {}, 'PublicInbox::Smsg'; + my $smsg = $ctx->{smsg} = bless {}, 'PublicInbox::Smsg'; $smsg->populate($eml); - print $out PublicInbox::View::eml_entry($ctx, $smsg, $eml, 1) or die; + print $out PublicInbox::View::eml_entry($ctx, $eml, 1) or die; } sub html_start { diff --git a/lib/PublicInbox/Feed.pm b/lib/PublicInbox/Feed.pm index 279106d28..476d946f5 100644 --- a/lib/PublicInbox/Feed.pm +++ b/lib/PublicInbox/Feed.pm @@ -51,7 +51,7 @@ sub new_html_i { my ($ctx, $eml) = @_; $ctx->zmore($ctx->html_top) if exists $ctx->{-html_tip}; - $eml and return PublicInbox::View::eml_entry($ctx, $ctx->{smsg}, $eml, + $eml and return PublicInbox::View::eml_entry($ctx, $eml, scalar @{$ctx->{msgs}}); my $smsg = shift @{$ctx->{msgs}} or $ctx->zmore(PublicInbox::View::pagination_footer( diff --git a/lib/PublicInbox/SearchView.pm b/lib/PublicInbox/SearchView.pm index 921992a5d..623b16fb2 100644 --- a/lib/PublicInbox/SearchView.pm +++ b/lib/PublicInbox/SearchView.pm @@ -294,7 +294,7 @@ sub mset_thread { sub mset_thread_i { my ($ctx, $eml) = @_; $ctx->zmore($ctx->html_top) if exists $ctx->{-html_tip}; - $eml and return PublicInbox::View::eml_entry($ctx, $ctx->{smsg}, $eml, + $eml and return PublicInbox::View::eml_entry($ctx, $eml, scalar @{$ctx->{msgs}}); my $smsg = shift @{$ctx->{msgs}} or $ctx->zmore(${delete($ctx->{skel})}); diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm index 16a0fcdfb..656953928 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
 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 . '
' . eml_entry($ctx, $smsg, $eml, 0) . '
' . $end; + my ($ctx, $eml) = @_; + my ($beg, $end) = thread_adj_level($ctx, $ctx->{level}); + $beg . '
' . eml_entry($ctx, $eml, 0) . '
' . $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});