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 651241F42D; Thu, 29 Mar 2018 10:28:29 +0000 (UTC) From: "Eric Wong (Contractor, The Linux Foundation)" To: meta@public-inbox.org Cc: "Eric Wong (Contractor, The Linux Foundation)" Subject: [PATCH 01/14] www: remove unnecessary ghost checks Date: Thu, 29 Mar 2018 10:28:06 +0000 Message-Id: <20180329102819.15234-2-e@80x24.org> In-Reply-To: <20180329102819.15234-1-e@80x24.org> References: <20180329102819.15234-1-e@80x24.org> List-Id: We do not need to care about ghosts at multiple call sites; they cannot have a {blob} field and we've stored the blob field in Xapian since SCHEMA_VERSION=13. --- lib/PublicInbox/Inbox.pm | 10 ++++------ lib/PublicInbox/Mbox.pm | 2 -- lib/PublicInbox/View.pm | 2 -- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/lib/PublicInbox/Inbox.pm b/lib/PublicInbox/Inbox.pm index 3097751..47b8630 100644 --- a/lib/PublicInbox/Inbox.pm +++ b/lib/PublicInbox/Inbox.pm @@ -270,12 +270,10 @@ sub msg_by_path ($$;$) { sub msg_by_smsg ($$;$) { my ($self, $smsg, $ref) = @_; - return unless defined $smsg; # ghost - - # backwards compat to fallback to msg_by_mid - # TODO: remove if we bump SCHEMA_VERSION in Search.pm: - defined(my $blob = $smsg->{blob}) or - return msg_by_path($self, mid2path($smsg->mid), $ref); + # ghosts may have undef smsg (from SearchThread.node) or + # no {blob} field (from each_smsg_by_mid) + return unless defined $smsg; + defined(my $blob = $smsg->{blob}) or return; my $str = git($self)->cat_file($blob, $ref); $$str =~ s/\A[\r\n]*From [^\r\n]*\r?\n//s if $str; diff --git a/lib/PublicInbox/Mbox.pm b/lib/PublicInbox/Mbox.pm index c14037f..381bcad 100644 --- a/lib/PublicInbox/Mbox.pm +++ b/lib/PublicInbox/Mbox.pm @@ -41,7 +41,6 @@ sub getline { } for (; !defined($cur) && $head != $tail; $head++) { my $smsg = PublicInbox::SearchMsg->get($head, $db, $ctx->{mid}); - next if $smsg->type ne 'mail'; my $mref = $ctx->{-inbox}->msg_by_smsg($smsg) or next; $cur = Email::Simple->new($mref); $cur = msg_str($ctx, $cur); @@ -66,7 +65,6 @@ sub emit_raw { for (; !defined($first) && $head != $tail; $head++) { my @args = ($head, $db, $mid); my $smsg = PublicInbox::SearchMsg->get(@args); - next if $smsg->type ne 'mail'; my $mref = $ibx->msg_by_smsg($smsg) or next; $first = Email::Simple->new($mref); } diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm index 5fb2b31..133c30a 100644 --- a/lib/PublicInbox/View.pm +++ b/lib/PublicInbox/View.pm @@ -63,7 +63,6 @@ sub msg_page { for (; !defined($first) && $head != $tail; $head++) { my @args = ($head, $db, $mid); my $smsg = PublicInbox::SearchMsg->get(@args); - next if $smsg->type ne 'mail'; $first = $ibx->msg_by_smsg($smsg); } if ($head != $tail) { @@ -85,7 +84,6 @@ sub msg_html_more { my $mid = $ctx->{mid}; for (; !defined($smsg) && $head != $tail; $head++) { my $m = PublicInbox::SearchMsg->get($head, $db, $mid); - next if $m->type ne 'mail'; $smsg = $ctx->{-inbox}->smsg_mime($m); } if ($head == $tail) { # done -- EW