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

Unified Diff: sdk/lib/_internal/pub/lib/src/entrypoint.dart

Issue 489943002: Don't recompute the package graph unnecessarily in Entrypoint. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes Created 6 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 | « no previous file | sdk/lib/_internal/pub/lib/src/package.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/pub/lib/src/entrypoint.dart
diff --git a/sdk/lib/_internal/pub/lib/src/entrypoint.dart b/sdk/lib/_internal/pub/lib/src/entrypoint.dart
index 16b19a59259207afabb4493ae3fd744c18a89e10..ce74b86d0a0aadd33667abdbd512851f1f5356f0 100644
--- a/sdk/lib/_internal/pub/lib/src/entrypoint.dart
+++ b/sdk/lib/_internal/pub/lib/src/entrypoint.dart
@@ -57,6 +57,9 @@ class Entrypoint {
/// If not provided to the entrypoint, it will be laoded lazily from disc.
LockFile _lockFile;
+ /// The graph of all packages reachable from the entrypoint.
+ PackageGraph _packageGraph;
+
/// Loads the entrypoint from a package at [rootDir].
///
/// If [packageSymlinks] is `true`, this will create a "packages" directory
@@ -139,11 +142,18 @@ class Entrypoint {
result.summarizeChanges(type, dryRun: dryRun);
- // TODO(nweiz): we've already parsed all the pubspecs and we know the
- // lockfile is up to date; there's got to be a way to re-use that
- // information here.
- //
- // Also, don't precompile stuff when the transitive dependencies
+ /// Build a package graph from the version solver results so we don't
+ /// have to reload and reparse all the pubspecs.
+ return Future.wait(ids.map((id) {
+ return cache.sources[id.source].getDirectory(id).then((dir) {
+ return new Package(result.pubspecs[id.name], dir);
+ });
+ }));
+ }).then((packages) {
+ _packageGraph = new PackageGraph(this, _lockFile,
+ new Map.fromIterable(packages, key: (package) => package.name));
+
+ // TODO(nweiz): don't precompile stuff when the transitive dependencies
// haven't changed.
return precompileExecutables().catchError((error, stackTrace) {
// Just log exceptions here. Since the method is just about acquiring
@@ -377,6 +387,8 @@ class Entrypoint {
/// Before loading, makes sure the lockfile and dependencies are installed
/// and up to date.
Future<PackageGraph> loadPackageGraph() {
+ if (_packageGraph != null) return new Future.value(_packageGraph);
+
return ensureLockFileIsUpToDate().then((_) {
return Future.wait(lockFile.packages.values.map((id) {
var source = cache.sources[id.source];
@@ -385,7 +397,8 @@ class Entrypoint {
})).then((packages) {
var packageMap = new Map.fromIterable(packages, key: (p) => p.name);
packageMap[root.name] = root;
- return new PackageGraph(this, lockFile, packageMap);
+ _packageGraph = new PackageGraph(this, lockFile, packageMap);
+ return _packageGraph;
});
});
}
« no previous file with comments | « no previous file | sdk/lib/_internal/pub/lib/src/package.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698