Skip to content

Commit 145c2fd

Browse files
gnpricechrisbobbe
authored andcommitted
autocomplete [nfc]: Use a break label to simplify a loop
I think I probably didn't know Dart had this feature when we originally wrote this loop.
1 parent e6791a9 commit 145c2fd

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

lib/model/autocomplete.dart

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -256,17 +256,13 @@ abstract class AutocompleteView<QueryT extends AutocompleteQuery, ResultT extend
256256
final Iterable<CandidateT> data = getSortedItemsToTest();
257257

258258
final iterator = data.iterator;
259-
bool isDone = false;
260-
while (!isDone) {
259+
outer: while (true) {
261260
assert(_query == query);
262261
if (await shouldStop()) return null;
263262
assert(_query == query);
264263

265264
for (int i = 0; i < 1000; i++) {
266-
if (!iterator.moveNext()) {
267-
isDone = true;
268-
break;
269-
}
265+
if (!iterator.moveNext()) break outer;
270266
final CandidateT item = iterator.current;
271267
final result = testItem(query, item);
272268
if (result != null) results.add(result);

0 commit comments

Comments
 (0)