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

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: Address comment. 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..4f1df90488355237b72866d04786b65987af6d12 100644
--- a/sdk/lib/async/future.dart
+++ b/sdk/lib/async/future.dart
@@ -485,8 +485,10 @@ abstract class Future<T> {
var nextIteration;
// Bind this callback explicitly so that each iteration isn't bound in the
// context of all the previous iterations' callbacks.
+ // This avoids, e.g., deeply nested stack traces from the stack trace
+ // package.
nextIteration = Zone.current.bindUnaryCallback((bool keepGoing) {
- if (keepGoing) {
+ while (keepGoing) {
FutureOr<bool> result;
try {
result = f();
@@ -500,10 +502,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