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 CE84A1F934 for ; Mon, 21 Dec 2020 07:51:22 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 1/5] inbox: delay ->version detection Date: Mon, 21 Dec 2020 07:51:18 +0000 Message-Id: <20201221075122.1587-2-e@80x24.org> In-Reply-To: <20201221075122.1587-1-e@80x24.org> References: <20201221075122.1587-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Our read-only code won't need to know the version until an inbox is accessed. This is a small step towards eliminating many stat() calls on read-only daemon startup. --- lib/PublicInbox/Inbox.pm | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/PublicInbox/Inbox.pm b/lib/PublicInbox/Inbox.pm index 8a3a0194..863a5de4 100644 --- a/lib/PublicInbox/Inbox.pm +++ b/lib/PublicInbox/Inbox.pm @@ -109,10 +109,6 @@ sub new { delete $opts->{feedmax}; } $opts->{nntpserver} ||= $pi_cfg->{'publicinbox.nntpserver'}; - my $dir = $opts->{inboxdir}; - if (defined $dir && -f "$dir/inbox.lock") { - $opts->{version} = 2; - } # allow any combination of multi-line or comma-delimited hide entries my $hide = {}; @@ -125,7 +121,9 @@ sub new { bless $opts, $class; } -sub version { $_[0]->{version} // 1 } +sub version { + $_[0]->{version} //= -f "$_[0]->{inboxdir}/inbox.lock" ? 2 : 1 +} sub git_epoch { my ($self, $epoch) = @_; # v2-only, callers always supply $epoch