From 20ddcb02821ff3bf8afd2c2279e0889492c93fd9 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 14 Jun 2019 17:13:04 +0000 Subject: search: require PublicInbox::Inbox ref here No sense in supporting multiple methods of initialization for an internal class. --- lib/PublicInbox/Inbox.pm | 2 +- lib/PublicInbox/Search.pm | 15 +++++---------- 2 files changed, 6 insertions(+), 11 deletions(-) (limited to 'lib') diff --git a/lib/PublicInbox/Inbox.pm b/lib/PublicInbox/Inbox.pm index c9330332..10f716ca 100644 --- a/lib/PublicInbox/Inbox.pm +++ b/lib/PublicInbox/Inbox.pm @@ -191,7 +191,7 @@ sub search ($;$) { my $srch = $self->{search} ||= eval { _cleanup_later($self); require PublicInbox::Search; - PublicInbox::Search->new($self, $self->{altid}); + PublicInbox::Search->new($self); }; ($over_only || eval { $srch->xdb }) ? $srch : undef; } diff --git a/lib/PublicInbox/Search.pm b/lib/PublicInbox/Search.pm index 9903f427..098c97cd 100644 --- a/lib/PublicInbox/Search.pm +++ b/lib/PublicInbox/Search.pm @@ -170,17 +170,12 @@ sub xdb ($) { } sub new { - my ($class, $mainrepo, $altid) = @_; - my $version = 1; - my $ibx = $mainrepo; - if (ref $ibx) { - $version = $ibx->{version} || 1; - $mainrepo = $ibx->{mainrepo}; - } + my ($class, $ibx) = @_; + ref $ibx or die "BUG: expected PublicInbox::Inbox object: $ibx"; my $self = bless { - mainrepo => $mainrepo, - altid => $altid, - version => $version, + mainrepo => $ibx->{mainrepo}, + altid => $ibx->{altid}, + version => $ibx->{version} // 1, }, $class; my $dir = xdir($self, 1); $self->{over_ro} = PublicInbox::Over->new("$dir/over.sqlite3"); -- cgit v1.2.3-24-ge0c7