From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 4/7] view: reduce indentation for skeleton generation
Date: Sat, 10 Dec 2016 03:43:02 +0000 [thread overview]
Message-ID: <20161210034305.2654-5-e@80x24.org> (raw)
In-Reply-To: <20161210034305.2654-1-e@80x24.org>
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 . "<a\nhref=\"$m\"$id>" . $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{<<a\nhref=#r$id>$html</a>>\n};
+ $d .= qq{<<a\nhref="$href"\nid=r$id>$html</a>>\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{<<a\nhref=#r$id>$html</a>>\n};
- $d .= qq{<<a\nhref="$href"\nid=r$id>$html</a>>\n};
- } else {
- $d .= qq{<<a\nhref="$href">$html</a>>\n};
- }
- $$dst .= $d;
+ $d .= qq{<<a\nhref="$href">$html</a>>\n};
}
+ my $dst = $ctx->{dst};
+ $$dst .= $d;
}
sub sort_ts {
--
EW
next prev parent reply other threads:[~2016-12-10 3:43 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-10 3:42 [PATCH 0/7] message threading fixes for WWW UI Eric Wong
2016-12-10 3:42 ` [PATCH 1/7] search: favor In-Reply-To over last References iff IRT exists Eric Wong
2016-12-10 3:43 ` [PATCH 2/7] view: favor SearchMsg for In-Reply-To over Email::MIME Eric Wong
2016-12-10 3:43 ` [PATCH 3/7] thread: fix comment describing its existence Eric Wong
2016-12-10 3:43 ` Eric Wong [this message]
2016-12-10 3:43 ` [PATCH 5/7] view: skip ghosts with no direct children Eric Wong
2016-12-10 3:43 ` [PATCH 6/7] thread: last Reference always wins Eric Wong
2016-12-10 3:43 ` [PATCH 7/7] search: always sort thread results in ascending time order Eric Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://public-inbox.org/README
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161210034305.2654-5-e@80x24.org \
--to=e@80x24.org \
--cc=meta@public-inbox.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/public-inbox.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).