From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 4F3D71F5B1 for ; Sun, 21 Jun 2020 19:23:26 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 2/2] imap: refill_xap: remove needless loop Date: Sun, 21 Jun 2020 19:23:25 +0000 Message-Id: <20200621192325.18165-3-e@yhbt.net> In-Reply-To: <20200621192325.18165-1-e@yhbt.net> References: <20200621192325.18165-1-e@yhbt.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: There's no need to loop when the first iteration guarantees a `return'. --- lib/PublicInbox/IMAP.pm | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/lib/PublicInbox/IMAP.pm b/lib/PublicInbox/IMAP.pm index 0508ae381dd..941ce3af495 100644 --- a/lib/PublicInbox/IMAP.pm +++ b/lib/PublicInbox/IMAP.pm @@ -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