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

Unified Diff: pkg/analyzer/lib/src/summary/bazel_summary.dart

Issue 2383233002: Cache Uri to Package and Package to node mappings. (Closed)
Patch Set: Created 4 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
« 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: pkg/analyzer/lib/src/summary/bazel_summary.dart
diff --git a/pkg/analyzer/lib/src/summary/bazel_summary.dart b/pkg/analyzer/lib/src/summary/bazel_summary.dart
index 60a132077929311f88955ce13ba2892d1091d6f6..b4413786a84f02ac7889a6ecd25bdf6449a08e42 100644
--- a/pkg/analyzer/lib/src/summary/bazel_summary.dart
+++ b/pkg/analyzer/lib/src/summary/bazel_summary.dart
@@ -110,9 +110,14 @@ class SummaryProvider {
final Map<Folder, List<Package>> folderToPackagesMap = {};
/**
- * Mapping from [Uri]s to corresponding [_LinkNode]s.
+ * Mapping from [Uri]s to corresponding [Package]s.
*/
- final Map<Uri, _LinkNode> uriToNodeMap = {};
+ final Map<Uri, Package> uriToPackageMap = {};
+
+ /**
+ * Mapping from [Package]s to corresponding [_LinkNode]s.
+ */
+ final Map<Package, _LinkNode> packageToNodeMap = {};
SummaryProvider(this.provider, this.getOutputFolder, AnalysisContext context)
: context = context,
@@ -162,17 +167,19 @@ class SummaryProvider {
*/
@visibleForTesting
Package getUnlinkedForUri(Uri uri) {
- Folder outputFolder = getOutputFolder(uri);
- if (outputFolder != null) {
- String uriStr = uri.toString();
- List<Package> packages = _getUnlinkedPackages(outputFolder);
- for (Package package in packages) {
- if (package._unitUris.contains(uriStr)) {
- return package;
+ return uriToPackageMap.putIfAbsent(uri, () {
+ Folder outputFolder = getOutputFolder(uri);
+ if (outputFolder != null) {
+ String uriStr = uri.toString();
+ List<Package> packages = _getUnlinkedPackages(outputFolder);
+ for (Package package in packages) {
+ if (package._unitUris.contains(uriStr)) {
+ return package;
+ }
}
}
- }
- return null;
+ return null;
+ });
}
/**
@@ -191,8 +198,8 @@ class SummaryProvider {
* bundle that contains [uri].
*/
_LinkNode _getLinkNodeForUri(Uri uri) {
- return uriToNodeMap.putIfAbsent(uri, () {
- Package package = getUnlinkedForUri(uri);
+ Package package = getUnlinkedForUri(uri);
+ return packageToNodeMap.putIfAbsent(package, () {
if (package == null) {
return null;
}
« 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