diff options
author | Eric Wong <e@80x24.org> | 2023-12-08 03:54:34 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2023-12-09 02:03:48 +0000 |
commit | 866dc178546a5b11610cbcfcdf2b87b03020a205 (patch) | |
tree | 974e5fc69e89c48308baa372caca130106679e80 /lib/PublicInbox/CodeSearch.pm | |
parent | 305e237b9e22ffed1b009f8f2b12bf99e8856748 (diff) | |
download | public-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/CodeSearch.pm')
-rw-r--r-- | lib/PublicInbox/CodeSearch.pm | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/lib/PublicInbox/CodeSearch.pm b/lib/PublicInbox/CodeSearch.pm index 3092718d..48697cdc 100644 --- a/lib/PublicInbox/CodeSearch.pm +++ b/lib/PublicInbox/CodeSearch.pm @@ -9,6 +9,7 @@ use v5.12; use parent qw(PublicInbox::Search); use PublicInbox::Config; use PublicInbox::Search qw(retry_reopen int_val xap_terms); +use PublicInbox::Compat qw(uniqstr); use Compress::Zlib qw(uncompress); use constant { AT => 0, # author time YYYYMMDDHHMMSS, dt: for mail) @@ -199,12 +200,11 @@ sub roots2paths { # for diagnostics do { my $mset = $enq->get_mset($off += $size, $lim); for my $x ($mset->items) { - my $tmp = xap_terms('P', $x->get_document); - push @$dirs, keys %$tmp; + push @$dirs, xap_terms('P', $x->get_document); } $size = $mset->size; } while ($size); - @$dirs = sort @$dirs; + @$dirs = sort(uniqstr(@$dirs)); } \%ret; } @@ -223,12 +223,9 @@ sub root_oids ($$) { my @ids = docids_of_git_dir $self, $git_dir or warn <<""; BUG? (non-fatal) `$git_dir' not indexed in $self->{topdir} - my %ret; - for my $docid (@ids) { - my @oids = xap_terms('G', $self->xdb, $docid); - @ret{@oids} = @oids; - } - sort keys %ret; + my @ret = map { xap_terms('G', $self->xdb, $_) } @ids; + @ret = uniqstr(@ret) if @ids > 1; + @ret; } sub paths2roots { |