From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: 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.0 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id CC69A209B9 for ; Sat, 10 Dec 2016 03:43:06 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 4/7] view: reduce indentation for skeleton generation Date: Sat, 10 Dec 2016 03:43:02 +0000 Message-Id: <20161210034305.2654-5-e@80x24.org> In-Reply-To: <20161210034305.2654-1-e@80x24.org> References: <20161210034305.2654-1-e@80x24.org> List-Id: This should reduce the number of subroutine calls needed for the common case of real (non-ghost) messages as well as shortening code. --- lib/PublicInbox/View.pm | 48 +++++++++++++++++++++++------------------------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm index feac601..c2e1ae7 100644 --- a/lib/PublicInbox/View.pm +++ b/lib/PublicInbox/View.pm @@ -767,8 +767,9 @@ sub _msg_date { sub fmt_ts { POSIX::strftime('%Y-%m-%d %k:%M', gmtime($_[0])) } -sub _skel_header { - my ($ctx, $smsg, $level) = @_; +sub skel_dump { + my ($ctx, $level, $node) = @_; + my $smsg = $node->{smsg} or return _skel_ghost($ctx, $level, $node); my $dst = $ctx->{dst}; my $cur = $ctx->{cur}; @@ -824,32 +825,29 @@ sub _skel_header { $$dst .= $d . "" . $end; } -sub skel_dump { +sub _skel_ghost { my ($ctx, $level, $node) = @_; - if (my $smsg = $node->{smsg}) { - _skel_header($ctx, $smsg, $level); + + my $mid = $node->{id}; + my $d = $ctx->{pct} ? ' [irrelevant] ' # search result + : ' [not found] '; + $d .= indent_for($level) . th_pfx($level); + my $upfx = $ctx->{-upfx}; + my $m = PublicInbox::Hval->new_msgid($mid); + my $href = $upfx . $m->{href} . '/'; + my $html = $m->as_html; + + my $mapping = $ctx->{mapping}; + my $map = $mapping->{$mid} if $mapping; + if ($map) { + my $id = id_compress($mid, 1); + $map->[0] = $d . qq{<$html>\n}; + $d .= qq{<$html>\n}; } else { - my $mid = $node->{id}; - my $dst = $ctx->{dst}; - my $d = $ctx->{pct} ? ' [irrelevant] ' # search result - : ' [not found] '; - $d .= indent_for($level) . th_pfx($level); - my $upfx = $ctx->{-upfx}; - my $m = PublicInbox::Hval->new_msgid($mid); - my $href = $upfx . $m->{href} . '/'; - my $html = $m->as_html; - - my $mapping = $ctx->{mapping}; - my $map = $mapping->{$mid} if $mapping; - if ($map) { - my $id = id_compress($mid, 1); - $map->[0] = $d . qq{<$html>\n}; - $d .= qq{<$html>\n}; - } else { - $d .= qq{<$html>\n}; - } - $$dst .= $d; + $d .= qq{<$html>\n}; } + my $dst = $ctx->{dst}; + $$dst .= $d; } sub sort_ts { -- EW