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

Unified Diff: pkg/front_end/lib/src/fasta/source/source_loader.dart

Issue 2709573005: fasta: Cache source bytes to ensure we use the same bytes for outline and bodies, Gives also around… (Closed)
Patch Set: Created 3 years, 10 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/front_end/lib/src/fasta/source/source_loader.dart
diff --git a/pkg/front_end/lib/src/fasta/source/source_loader.dart b/pkg/front_end/lib/src/fasta/source/source_loader.dart
index d1d3da25def111eb2bd7b0cdbbeafc0e34921d35..884773d505f68bd8867ec1015e7b0c77cf7d7db0 100644
--- a/pkg/front_end/lib/src/fasta/source/source_loader.dart
+++ b/pkg/front_end/lib/src/fasta/source/source_loader.dart
@@ -71,6 +71,8 @@ import '../ast_kind.dart' show
AstKind;
class SourceLoader<L> extends Loader<L> {
+ final Map<Uri, List<int>> sourceBytes = <Uri, List<int>>{};
+
// Used when building directly to kernel.
ClassHierarchy hierarchy;
CoreTypes coreTypes;
@@ -88,7 +90,10 @@ class SourceLoader<L> extends Loader<L> {
return inputError(library.uri, -1, "Not found: ${library.uri}.");
}
try {
- List<int> bytes = await readBytesFromFile(uri);
+ List<int> bytes = sourceBytes[uri];
+ if (bytes == null) {
+ bytes = sourceBytes[uri] = await readBytesFromFile(uri);
+ }
byteCount += bytes.length - 1;
ScannerResult result = scan(bytes);
Token token = result.tokens;
« 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