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

Unified Diff: sdk/lib/_internal/pub/lib/src/barback/build_environment.dart

Issue 222643003: Code review change for r34634. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/pub/lib/src/barback/build_environment.dart
diff --git a/sdk/lib/_internal/pub/lib/src/barback/build_environment.dart b/sdk/lib/_internal/pub/lib/src/barback/build_environment.dart
index 1b6c5c5f70cd5cfd7166f522baa7797881ff2ca7..78a459cdd82ca4a7a51639e5b720c2bc783f1491 100644
--- a/sdk/lib/_internal/pub/lib/src/barback/build_environment.dart
+++ b/sdk/lib/_internal/pub/lib/src/barback/build_environment.dart
@@ -290,20 +290,15 @@ class BuildEnvironment {
///
/// If no server can serve [url], completes to `null`.
Future<AssetId> getAssetIdForUrl(Uri url) {
- var iterator = _directories.values.toList().iterator;
- iterate() {
- if (!iterator.moveNext()) return null;
-
- return iterator.current.server.then((server) {
- if (server.address.host == url.host && server.port == url.port) {
- return server.urlToId(url);
- } else {
- return iterate();
- }
- });
- }
-
- return syncFuture(iterate);
+ return Future.wait(_directories.values.map((dir) => dir.server))
+ .then((servers) {
+ var server = servers.firstWhere(
+ (server) => server.address.host == url.host &&
+ server.port == url.port,
+ orElse: () => null);
+ if (server == null) return null;
+ return server.urlToId(url);
+ });
}
/// Determines if [sourcePath] is contained within any of the directories in
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698