about summary refs log tree commit homepage
path: root/lib/PublicInbox/LeiStore.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2023-12-08 03:54:34 +0000
committerEric Wong <e@80x24.org>2023-12-09 02:03:48 +0000
commit866dc178546a5b11610cbcfcdf2b87b03020a205 (patch)
tree974e5fc69e89c48308baa372caca130106679e80 /lib/PublicInbox/LeiStore.pm
parent305e237b9e22ffed1b009f8f2b12bf99e8856748 (diff)
downloadpublic-inbox-866dc178546a5b11610cbcfcdf2b87b03020a205.tar.gz
Most xap_terms callers do not benefit from the hashref
return value, and we can delay hashmap use until
List::Util::uniqstr if needed.
Diffstat (limited to 'lib/PublicInbox/LeiStore.pm')
-rw-r--r--lib/PublicInbox/LeiStore.pm13
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/PublicInbox/LeiStore.pm b/lib/PublicInbox/LeiStore.pm
index aebb85a9..a752174d 100644
--- a/lib/PublicInbox/LeiStore.pm
+++ b/lib/PublicInbox/LeiStore.pm
@@ -27,6 +27,7 @@ use PublicInbox::MDA;
 use PublicInbox::Spawn qw(spawn);
 use PublicInbox::MdirReader;
 use PublicInbox::LeiToMail;
+use PublicInbox::Compat qw(uniqstr);
 use File::Temp qw(tmpnam);
 use POSIX ();
 use IO::Handle (); # ->autoflush
@@ -341,15 +342,15 @@ sub _add_vmd ($$$$) {
 sub _docids_and_maybe_kw ($$) {
         my ($self, $docids) = @_;
         return $docids unless wantarray;
-        my $kw = {};
+        my (@kw, $idx, @tmp);
         for my $num (@$docids) { # likely only 1, unless ContentHash changes
                 # can't use ->search->msg_keywords on uncommitted docs
-                my $idx = $self->{priv_eidx}->idx_shard($num);
-                my $tmp = eval { $idx->ipc_do('get_terms', 'K', $num) };
-                if ($@) { warn "#$num get_terms: $@" }
-                else { @$kw{keys %$tmp} = values(%$tmp) };
+                $idx = $self->{priv_eidx}->idx_shard($num);
+                @tmp = eval { $idx->ipc_do('get_terms', 'K', $num) };
+                $@ ? warn("#$num get_terms: $@") : push(@kw, @tmp);
         }
-        ($docids, [ sort keys %$kw ]);
+        @kw = sort(uniqstr(@kw)) if @$docids > 1;
+        ($docids, \@kw);
 }
 
 sub _reindex_1 { # git->cat_async callback