Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(686)

Unified Diff: sdk/lib/async/future.dart

Issue 2853203002: Change Future.doWhile to use a loop for non-future results instead of recursion. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/lib/async/futures_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/async/future.dart
diff --git a/sdk/lib/async/future.dart b/sdk/lib/async/future.dart
index 3841ff8fec36fa6a48f67882f6a3789e5dd91731..7f0c2a333acc536515d680a033dfa006b64c7a4c 100644
--- a/sdk/lib/async/future.dart
+++ b/sdk/lib/async/future.dart
@@ -486,7 +486,7 @@ abstract class Future<T> {
// Bind this callback explicitly so that each iteration isn't bound in the
// context of all the previous iterations' callbacks.
floitsch 2017/05/02 10:16:56 Mention stacktrace package here.
nextIteration = Zone.current.bindUnaryCallback((bool keepGoing) {
- if (keepGoing) {
+ while (keepGoing) {
FutureOr<bool> result;
try {
result = f();
@@ -500,10 +500,9 @@ abstract class Future<T> {
result.then(nextIteration, onError: doneSignal._completeError);
return;
}
- nextIteration(result);
- } else {
- doneSignal._complete(null);
+ keepGoing = result;
}
+ doneSignal._complete(null);
}, runGuarded: true);
nextIteration(true);
return doneSignal;
« no previous file with comments | « no previous file | tests/lib/async/futures_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698