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 2EB931FA17 for ; Wed, 2 Sep 2020 11:04:23 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 07/11] search: remove {over_ro} field Date: Wed, 2 Sep 2020 11:04:17 +0000 Message-Id: <20200902110421.30905-8-e@80x24.org> In-Reply-To: <20200902110421.30905-1-e@80x24.org> References: <20200902110421.30905-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Only inbox accesses the read-only {over}, now, instead of going through ->search. This simplifies our object graph and avoids potentially redundant FDs and DB handles pointing to the same over.sqlite3 file. --- lib/PublicInbox/Inbox.pm | 11 +++++------ lib/PublicInbox/Search.pm | 2 -- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/lib/PublicInbox/Inbox.pm b/lib/PublicInbox/Inbox.pm index 4005954e..b0894a7d 100644 --- a/lib/PublicInbox/Inbox.pm +++ b/lib/PublicInbox/Inbox.pm @@ -206,14 +206,13 @@ EOF }; } -sub over ($) { - my ($self) = @_; - my $srch = search($self, 1) or return; - $self->{over} //= eval { - my $over = $srch->{over_ro}; +sub over { + $_[0]->{over} //= eval { + my $srch = search($_[0], 1) or return; + my $over = PublicInbox::Over->new("$srch->{xpfx}/over.sqlite3"); $over->dbh; # may fail $over; - } + }; } sub try_cat { diff --git a/lib/PublicInbox/Search.pm b/lib/PublicInbox/Search.pm index cfa942b2..b07f4ea6 100644 --- a/lib/PublicInbox/Search.pm +++ b/lib/PublicInbox/Search.pm @@ -265,8 +265,6 @@ sub new { ibx_ver => $ibx->version, }, $class; xpfx_init($self); - my $dir = xdir($self, 1); - $self->{over_ro} = PublicInbox::Over->new("$dir/over.sqlite3"); $self; }