about summary refs log tree commit homepage
path: root/lib/PublicInbox/Search.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-06-23 07:14:20 -0400
committerEric Wong <e@80x24.org>2021-06-23 19:24:48 +0000
commit4d594e98063aaad1ce9a90709af7edc5c44a0163 (patch)
tree50e8ac2cb3b74405ae66bf022f10001fe9c69d32 /lib/PublicInbox/Search.pm
parent2016078cefa7e4438217e54bb0421a5d5f0b151f (diff)
downloadpublic-inbox-4d594e98063aaad1ce9a90709af7edc5c44a0163.tar.gz
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.
Diffstat (limited to 'lib/PublicInbox/Search.pm')
-rw-r--r--lib/PublicInbox/Search.pm22
1 files changed, 9 insertions, 13 deletions
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;