]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/Search.pm
searchidx: fix (undocumented) --skip-docdata handling
[public-inbox.git] / lib / PublicInbox / Search.pm
index b07f4ea6a7285315482ac79ec6a9d1de8f0bf8f3..0321ca9352944d720a0962df8e3d1097ca9de68f 100644 (file)
@@ -7,6 +7,7 @@ package PublicInbox::Search;
 use strict;
 use parent qw(Exporter);
 our @EXPORT_OK = qw(mdocid);
+use List::Util qw(max);
 
 # values for searching, changing the numeric value breaks
 # compatibility with old indices (so don't change them it)
@@ -89,9 +90,6 @@ sub load_xapian () {
                $ENQ_ASCENDING = $x eq 'Xapian' ?
                                1 : Search::Xapian::ENQ_ASCENDING();
 
-               # for Smsg:
-               *PublicInbox::Smsg::sortable_unserialise =
-                                               $Xap.'::sortable_unserialise';
                # n.b. FLAG_PURE_NOT is expensive not suitable for a public
                # website as it could become a denial-of-service vector
                # FLAG_PHRASE also seems to cause performance problems chert
@@ -203,7 +201,9 @@ sub _xdb ($) {
 
                # We need numeric sorting so shard[0] is first for reading
                # Xapian metadata, if needed
-               for (sort { $a <=> $b } grep(/\A[0-9]+\z/, readdir($dh))) {
+               my $last = max(grep(/\A[0-9]+\z/, readdir($dh)));
+               return if !defined($last);
+               for (0..$last) {
                        my $shard_dir = "$dir/$_";
                        if (-d $shard_dir && -r _) {
                                push @xdb, $X{Database}->new($shard_dir);