Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 part of dart.async; | 5 part of dart.async; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * An object representing a delayed computation. | 8 * An object representing a delayed computation. |
| 9 * | 9 * |
| 10 * A [Future] is used to represent a potential value, or error, | 10 * A [Future] is used to represent a potential value, or error, |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 174 | 174 |
| 175 /** | 175 /** |
| 176 * A future whose value is available in the next event-loop iteration. | 176 * A future whose value is available in the next event-loop iteration. |
| 177 * | 177 * |
| 178 * If [value] is not a [Future], using this constructor is equivalent | 178 * If [value] is not a [Future], using this constructor is equivalent |
| 179 * to [:new Future<T>.sync(() => value):]. | 179 * to [:new Future<T>.sync(() => value):]. |
| 180 * | 180 * |
| 181 * Use [Completer] to create a Future and complete it later. | 181 * Use [Completer] to create a Future and complete it later. |
| 182 */ | 182 */ |
| 183 factory Future.value([value]) { | 183 factory Future.value([value]) { |
| 184 if (value == null) return _nullFuture; | |
|
sra1
2015/06/15 16:17:40
What is the purpose of this change?
I think this
Lasse Reichstein Nielsen
2015/06/15 16:24:42
Ack, true.
The purpose is entirely to save some sp
Lasse Reichstein Nielsen
2015/06/16 09:25:12
Rolling this change back.
| |
| 184 return new _Future<T>.immediate(value); | 185 return new _Future<T>.immediate(value); |
| 185 } | 186 } |
| 186 | 187 |
| 187 /** | 188 /** |
| 188 * A future that completes with an error in the next event-loop iteration. | 189 * A future that completes with an error in the next event-loop iteration. |
| 189 * | 190 * |
| 190 * If [error] is `null`, it is replaced by a [NullThrownError]. | 191 * If [error] is `null`, it is replaced by a [NullThrownError]. |
| 191 * | 192 * |
| 192 * Use [Completer] to create a future and complete it later. | 193 * Use [Completer] to create a future and complete it later. |
| 193 */ | 194 */ |
| (...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 720 if (replacement != null) { | 721 if (replacement != null) { |
| 721 error = _nonNullError(replacement.error); | 722 error = _nonNullError(replacement.error); |
| 722 stackTrace = replacement.stackTrace; | 723 stackTrace = replacement.stackTrace; |
| 723 } | 724 } |
| 724 result._completeError(error, stackTrace); | 725 result._completeError(error, stackTrace); |
| 725 } | 726 } |
| 726 | 727 |
| 727 /** Helper function that converts `null` to a [NullThrownError]. */ | 728 /** Helper function that converts `null` to a [NullThrownError]. */ |
| 728 Object _nonNullError(Object error) => | 729 Object _nonNullError(Object error) => |
| 729 (error != null) ? error : new NullThrownError(); | 730 (error != null) ? error : new NullThrownError(); |
| OLD | NEW |