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

Unified Diff: pkg/analyzer/lib/src/dart/analysis/driver.dart

Issue 2440343002: Cache URIs resolution. (Closed)
Patch Set: Created 4 years, 2 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/dart/analysis/driver.dart
diff --git a/pkg/analyzer/lib/src/dart/analysis/driver.dart b/pkg/analyzer/lib/src/dart/analysis/driver.dart
index 045d9c60f578ad4ba21cf7d3669696a66016a7db..8439bcc033aaf947c3e599f035cea398a5a7072b 100644
--- a/pkg/analyzer/lib/src/dart/analysis/driver.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/driver.dart
@@ -126,6 +126,12 @@ class AnalysisDriver {
final _filesToAnalyze = new LinkedHashSet<String>();
/**
+ * The mapping of [Uri]s to the mapping of textual URIs to the [Source]
+ * that correspond in the current [_sourceFactory].
Paul Berry 2016/10/24 12:00:48 I'm having trouble parsing this comment. Consider
scheglov 2016/10/24 17:51:34 Done. Thank you.
+ */
+ final _uriResolutionCache = <Uri, Map<String, Source>>{};
+
+ /**
* The current file state.
*
* It maps file paths to the MD5 hash of the file content.
@@ -807,7 +813,9 @@ class _File {
* Return the [_File] for the [uri] referenced in this file.
*/
_File resolveUri(String uri) {
- Source uriSource = driver._sourceFactory.resolveUri(source, uri);
+ Source uriSource = driver._uriResolutionCache
+ .putIfAbsent(this.uri, () => <String, Source>{})
+ .putIfAbsent(uri, () => driver._sourceFactory.resolveUri(source, uri));
Paul Berry 2016/10/24 12:00:48 This seems like a rather minor optimization compar
scheglov 2016/10/24 17:51:34 I agree about unnecessary optimizations. Adding TO
return new _File(driver, uriSource);
}
« 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