diff options
author | Eric Wong <e@yhbt.net> | 2020-07-24 05:55:55 +0000 |
---|---|---|
committer | Eric Wong <e@yhbt.net> | 2020-07-25 20:48:18 +0000 |
commit | 298c806d51f31796caa65da70ab6bfa310db614a (patch) | |
tree | e1a99d59c1cb66c7033d5cca317769272ac21d86 /lib/PublicInbox/Search.pm | |
parent | dfbe27bb5533ef391b214692f25e2823b20064ac (diff) | |
download | public-inbox-298c806d51f31796caa65da70ab6bfa310db614a.tar.gz |
Instead, storing {xdir} will allow us to avoid string concatenation in the read-only path and save us a little hash entry space.
Diffstat (limited to 'lib/PublicInbox/Search.pm')
-rw-r--r-- | lib/PublicInbox/Search.pm | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/lib/PublicInbox/Search.pm b/lib/PublicInbox/Search.pm index 55eee41c..4e08aed7 100644 --- a/lib/PublicInbox/Search.pm +++ b/lib/PublicInbox/Search.pm @@ -164,15 +164,10 @@ chomp @HELP; sub xdir ($;$) { my ($self, $rdonly) = @_; - if ($self->{ibx_ver} == 1) { - "$self->{inboxdir}/public-inbox/xapian" . SCHEMA_VERSION; - } else { - my $dir = "$self->{inboxdir}/xap" . SCHEMA_VERSION; - return $dir if $rdonly; - - my $shard = $self->{shard}; - defined $shard or die "shard not given"; - $dir .= "/$shard"; + if ($rdonly || !defined($self->{shard})) { + $self->{xpfx}; + } else { # v2 only: + "$self->{xpfx}/$self->{shard}"; } } @@ -220,14 +215,24 @@ sub xdb ($) { }; } +sub xpfx_init ($) { + my ($self) = @_; + if ($self->{ibx_ver} == 1) { + $self->{xpfx} .= '/public-inbox/xapian' . SCHEMA_VERSION; + } else { + $self->{xpfx} .= '/xap'.SCHEMA_VERSION; + } +} + sub new { my ($class, $ibx) = @_; ref $ibx or die "BUG: expected PublicInbox::Inbox object: $ibx"; my $self = bless { - inboxdir => $ibx->{inboxdir}, + xpfx => $ibx->{inboxdir}, # for xpfx_init altid => $ibx->{altid}, ibx_ver => $ibx->version, }, $class; + xpfx_init($self); my $dir = xdir($self, 1); $self->{over_ro} = PublicInbox::Over->new("$dir/over.sqlite3"); $self; |