]> Sergey Matveev's repositories - public-inbox.git/commitdiff
imap: refill_xap: remove needless loop
authorEric Wong <e@yhbt.net>
Sun, 21 Jun 2020 19:23:25 +0000 (19:23 +0000)
committerEric Wong <e@yhbt.net>
Tue, 23 Jun 2020 00:22:06 +0000 (00:22 +0000)
There's no need to loop when the first iteration guarantees
a `return'.

lib/PublicInbox/IMAP.pm

index d8b1fce109ea151bdda1a6438d7d2f75219c332c..dec10d6142ba5c4ac82038d85b85cf6a32da65fb 100644 (file)
@@ -1172,16 +1172,13 @@ sub refill_xap ($$$$) {
        my $srch = $self->{ibx}->search;
        my $opt = { mset => 2, limit => 1000 };
        my $nshard = $srch->{nshard} // 1;
-       while (1) {
-               my $mset = $srch->query("$q uid:$beg..$end", $opt);
-               @$uids = map { mdocid($nshard, $_) } $mset->items;
-               if (@$uids) {
-                       $range_info->[0] = $uids->[-1] + 1; # update $beg
-                       return;
-               } else { # all done
-                       return 0;
-               }
+       my $mset = $srch->query("$q uid:$beg..$end", $opt);
+       @$uids = map { mdocid($nshard, $_) } $mset->items;
+       if (@$uids) {
+               $range_info->[0] = $uids->[-1] + 1; # update $beg
+               return; # possibly more
        }
+       0; # all done
 }
 
 sub search_xap_range { # long_response