unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
* [PATCH] search: all_terms: remove needless prefix check
@ 2023-08-16  8:07 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2023-08-16  8:07 UTC (permalink / raw)
  To: meta

The ->allterms_{begin,end} methods of Xapian::Database already
filter match on prefix natively.   Thus there's no need to do
filtering ourselves (unlike per-document ->termlist_{begin/end})
---
 lib/PublicInbox/Search.pm | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/lib/PublicInbox/Search.pm b/lib/PublicInbox/Search.pm
index a4fef17b..b2de3450 100644
--- a/lib/PublicInbox/Search.pm
+++ b/lib/PublicInbox/Search.pm
@@ -576,12 +576,9 @@ sub all_terms {
 	my $end = $self->{xdb}->allterms_end($pfx);
 	my %ret;
 	for (; $cur != $end; $cur++) {
-		my $tn = $cur->get_termname;
-		index($tn, $pfx) == 0 and
-			$ret{substr($tn, length($pfx))} = undef;
+		$ret{substr($cur->get_termname, length($pfx))} = undef;
 	}
 	wantarray ? (sort keys %ret) : \%ret;
 }
 
-
 1;

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2023-08-16  8:07 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-16  8:07 [PATCH] search: all_terms: remove needless prefix check Eric Wong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).