From 4d594e98063aaad1ce9a90709af7edc5c44a0163 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 23 Jun 2021 07:14:20 -0400 Subject: search: make xap_terms easier-to-use and use it more This allows us to simplify callers throughout, and exceptions are can no longer be silently hidden. MiscSearch now uses xap_terms for looking up eidx_key terms for a code reduction. We also simplify LeiStore->_msg_kw for runtime use by moving the MsetIterator handling into t/lei_store.t test case. --- lib/PublicInbox/Search.pm | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'lib/PublicInbox/Search.pm') diff --git a/lib/PublicInbox/Search.pm b/lib/PublicInbox/Search.pm index 59a5a3b0..7e19e616 100644 --- a/lib/PublicInbox/Search.pm +++ b/lib/PublicInbox/Search.pm @@ -557,19 +557,15 @@ sub get_pct ($) { # mset item sub xap_terms ($$;@) { my ($pfx, $xdb_or_doc, @docid) = @_; # @docid may be empty () my %ret; - eval { - my $end = $xdb_or_doc->termlist_end(@docid); - my $cur = $xdb_or_doc->termlist_begin(@docid); - for (; $cur != $end; $cur++) { - $cur->skip_to($pfx); - last if $cur == $end; - my $tn = $cur->get_termname; - if (index($tn, $pfx) == 0) { - $ret{substr($tn, length($pfx))} = undef; - } - } - }; - \%ret; + my $end = $xdb_or_doc->termlist_end(@docid); + my $cur = $xdb_or_doc->termlist_begin(@docid); + for (; $cur != $end; $cur++) { + $cur->skip_to($pfx); + last if $cur == $end; + my $tn = $cur->get_termname; + $ret{substr($tn, length($pfx))} = undef if !index($tn, $pfx); + } + wantarray ? sort(keys(%ret)) : \%ret; } 1; -- cgit v1.2.3-24-ge0c7