about summary refs log tree commit homepage
path: root/lib
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2016-12-10 01:09:48 +0000
committerEric Wong <e@80x24.org>2016-12-10 03:23:46 +0000
commit43288c0a9de93d0e73af57e9525f2053f29f10bb (patch)
treeb48d1ef3852dbc1ef69cb66cc1b753e88aa6f2af /lib
parent274c7932e1dda688eb4b31e04db34992f0a0eedc (diff)
downloadpublic-inbox-43288c0a9de93d0e73af57e9525f2053f29f10bb.tar.gz
This should reduce the number of subroutine calls needed
for the common case of real (non-ghost) messages as well
as shortening code.
Diffstat (limited to 'lib')
-rw-r--r--lib/PublicInbox/View.pm48
1 files changed, 23 insertions, 25 deletions
diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index feac6015..c2e1ae76 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{&lt;<a\nhref=#r$id>$html</a>&gt;\n};
+                $d .= qq{&lt;<a\nhref="$href"\nid=r$id>$html</a>&gt;\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{&lt;<a\nhref=#r$id>$html</a>&gt;\n};
-                        $d .= qq{&lt;<a\nhref="$href"\nid=r$id>$html</a>&gt;\n};
-                } else {
-                        $d .= qq{&lt;<a\nhref="$href">$html</a>&gt;\n};
-                }
-                $$dst .= $d;
+                $d .= qq{&lt;<a\nhref="$href">$html</a>&gt;\n};
         }
+        my $dst = $ctx->{dst};
+        $$dst .= $d;
 }
 
 sub sort_ts {