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

Unified Diff: pkg/dev_compiler/lib/src/compiler/source_map_printer.dart

Issue 2839733003: Cache path -> URI mapping in SourceMapPrintingContext. (Closed)
Patch Set: Created 3 years, 8 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/dev_compiler/lib/src/compiler/source_map_printer.dart
diff --git a/pkg/dev_compiler/lib/src/compiler/source_map_printer.dart b/pkg/dev_compiler/lib/src/compiler/source_map_printer.dart
index b3cd932004444890e3329a7297c62e6483611274..e164f011e07d6eda46afccbe1c4f6ed71c2af3d1 100644
--- a/pkg/dev_compiler/lib/src/compiler/source_map_printer.dart
+++ b/pkg/dev_compiler/lib/src/compiler/source_map_printer.dart
@@ -19,6 +19,9 @@ class SourceMapPrintingContext extends JS.SimpleJavaScriptPrintingContext {
/// The source_maps builder we write JavaScript code to.
final sourceMap = new SourceMapBuilder();
+ /// The cache of URIs for paths.
+ final _sourceUrlCache = <String, Object>{};
+
CompilationUnit unit;
String sourcePath;
AstNode _currentTopLevelDeclaration;
@@ -97,10 +100,12 @@ class SourceMapPrintingContext extends JS.SimpleJavaScriptPrintingContext {
if (next.lineNumber == loc.lineNumber + 1) {
loc = next;
}
- var sourceUrl =
- sourcePath.startsWith('dart:') || sourcePath.startsWith('package:')
- ? sourcePath
- : new Uri.file(sourcePath);
+ var sourceUrl = _sourceUrlCache.putIfAbsent(
+ sourcePath,
+ () =>
+ sourcePath.startsWith('dart:') || sourcePath.startsWith('package:')
+ ? sourcePath
+ : new Uri.file(sourcePath));
sourceMap.addLocation(
new SourceLocation(offset,
sourceUrl: sourceUrl,
« 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