* [PATCH 2/2] imap: refill_xap: remove needless loop
2020-06-21 19:23 6% [PATCH 0/2] imap: search fixes Eric Wong
@ 2020-06-21 19:23 7% ` Eric Wong
0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2020-06-21 19:23 UTC (permalink / raw)
To: meta
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
^ permalink raw reply related [relevance 7%]
* [PATCH 0/2] imap: search fixes
@ 2020-06-21 19:23 6% Eric Wong
2020-06-21 19:23 7% ` [PATCH 2/2] imap: refill_xap: remove needless loop Eric Wong
0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2020-06-21 19:23 UTC (permalink / raw)
To: meta
Some bugs I noticed while retooling -watch to work as an
IMAP (and NNTP) client.
Eric Wong (2):
imap: *SEARCH: return no results for out-of-range queries
imap: refill_xap: remove needless loop
lib/PublicInbox/IMAP.pm | 23 ++++++++++-------------
lib/PublicInbox/IMAPsearchqp.pm | 4 ++--
t/imapd.t | 11 +++++++++--
3 files changed, 21 insertions(+), 17 deletions(-)
^ permalink raw reply [relevance 6%]
Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2020-06-21 19:23 6% [PATCH 0/2] imap: search fixes Eric Wong
2020-06-21 19:23 7% ` [PATCH 2/2] imap: refill_xap: remove needless loop Eric Wong
Code repositories for project(s) associated with this public inbox
https://80x24.org/public-inbox.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).