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

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

Issue 1281523003: dart2js: Don't zone-register callbacks in async functions for every await. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Use origin instead of declaration. (already has the right type). Created 5 years, 4 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 | « sdk/lib/_internal/js_runtime/lib/js_helper.dart ('k') | tests/compiler/dart2js/mock_compiler.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/async/future_impl.dart
diff --git a/sdk/lib/async/future_impl.dart b/sdk/lib/async/future_impl.dart
index 980f0caa4f4a724827b30d5fea32845e7961392e..9fa1e57090e2583c3485efbd6d9f6a41f5f16da6 100644
--- a/sdk/lib/async/future_impl.dart
+++ b/sdk/lib/async/future_impl.dart
@@ -203,13 +203,19 @@ class _Future<T> implements Future<T> {
}
Future then(f(T value), { Function onError }) {
- _Future result = new _Future();
- if (!identical(result._zone, _ROOT_ZONE)) {
- f = result._zone.registerUnaryCallback(f);
+ Zone currentZone = Zone.current;
+ if (!identical(currentZone, _ROOT_ZONE)) {
+ f = currentZone.registerUnaryCallback(f);
if (onError != null) {
- onError = _registerErrorHandler(onError, result._zone);
+ onError = _registerErrorHandler(onError, currentZone);
}
}
+ return _thenNoZoneRegistration(f, onError);
+ }
+
+ // This function is used by async/await.
+ Future _thenNoZoneRegistration(f(T value), Function onError) {
+ _Future result = new _Future();
_addListener(new _FutureListener.then(result, f, onError));
return result;
}
« no previous file with comments | « sdk/lib/_internal/js_runtime/lib/js_helper.dart ('k') | tests/compiler/dart2js/mock_compiler.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698