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

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

Issue 559833004: Cache snapshots of (mostly) immutable transformer phases. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes Created 6 years, 3 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
Index: sdk/lib/_internal/pub/lib/src/package_graph.dart
diff --git a/sdk/lib/_internal/pub/lib/src/package_graph.dart b/sdk/lib/_internal/pub/lib/src/package_graph.dart
index 4470e51bc6ae1abde3ab918cfe87ebd080e38719..c82a6fb1cdf649a97de09693e966520c6dba03f1 100644
--- a/sdk/lib/_internal/pub/lib/src/package_graph.dart
+++ b/sdk/lib/_internal/pub/lib/src/package_graph.dart
@@ -4,6 +4,7 @@
library pub.package_graph;
+import 'barback/transformer_cache.dart';
import 'entrypoint.dart';
import 'lock_file.dart';
import 'package.dart';
@@ -28,8 +29,26 @@ class PackageGraph {
/// A map of transitive dependencies for each package.
Map<String, Set<Package>> _transitiveDependencies;
+ /// The transformer cache, if it's been loaded.
+ TransformerCache _transformerCache;
+
PackageGraph(this.entrypoint, this.lockFile, this.packages);
+ /// Loads the transformer cache for this graph.
+ ///
+ /// This may only be called if [entrypoint] represents a physical package.
+ /// This may modify the cache.
+ TransformerCache loadTransformerCache() {
+ if (_transformerCache == null) {
+ if (entrypoint.root.dir == null) {
+ throw new StateError("Can't load the transformer cache for virtual "
+ "entrypoint ${entrypoint.root.name}.");
+ }
+ _transformerCache = new TransformerCache.load(this);
+ }
+ return _transformerCache;
+ }
+
/// Returns all transitive dependencies of [package].
///
/// For the entrypoint this returns all packages in [packages], which includes

Powered by Google App Engine
This is Rietveld 408576698