[vm] Check for common case (_Future) before uncommon case (is! Future / 3rd party future)
TEST=ci
Change-Id: Iac123e20a889d8b3152bd3934c12ed012aebd8d0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231944
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
diff --git a/sdk/lib/_internal/vm/lib/async_patch.dart b/sdk/lib/_internal/vm/lib/async_patch.dart
index ee371e7..0e4dcd1 100644
--- a/sdk/lib/_internal/vm/lib/async_patch.dart
+++ b/sdk/lib/_internal/vm/lib/async_patch.dart
@@ -70,10 +70,10 @@
Future _awaitHelper(var object, dynamic Function(dynamic) thenCallback,
dynamic Function(dynamic, StackTrace) errorCallback, Function awaiter) {
late _Future future;
- if (object is! Future) {
- future = new _Future().._setValue(object);
- } else if (object is _Future) {
+ if (object is _Future) {
future = object;
+ } else if (object is! Future) {
+ future = new _Future().._setValue(object);
} else {
return object.then(thenCallback, onError: errorCallback);
}