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

Unified Diff: pkg/kernel/lib/binary/ast_from_binary.dart

Issue 2729913005: [Fasta] include source code in dill (Closed)
Patch Set: Use Uint8List.view when possible Created 3 years, 9 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 | « pkg/kernel/lib/ast.dart ('k') | pkg/kernel/lib/binary/ast_to_binary.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/kernel/lib/binary/ast_from_binary.dart
diff --git a/pkg/kernel/lib/binary/ast_from_binary.dart b/pkg/kernel/lib/binary/ast_from_binary.dart
index a4d4a941efecb06d591a67e197507975cf2e9fc3..aa9641b672f5901a4a675b1089cd4fb6f5e31dbc 100644
--- a/pkg/kernel/lib/binary/ast_from_binary.dart
+++ b/pkg/kernel/lib/binary/ast_from_binary.dart
@@ -4,6 +4,7 @@
library kernel.ast_from_binary;
import 'dart:convert';
+import 'dart:typed_data';
import '../ast.dart';
import '../transformations/flags.dart';
@@ -74,6 +75,13 @@ class BinaryBuilder {
readByte();
}
+ List<int> readUtf8Bytes() {
+ List<int> bytes = new Uint8List(readUInt());
+ bytes.setRange(0, bytes.length, _bytes, _byteIndex);
+ _byteIndex += bytes.length;
+ return bytes;
+ }
+
String readStringEntry() {
int numBytes = readUInt();
// Utf8Decoder will skip leading BOM characters, but we must preserve them.
@@ -271,7 +279,7 @@ class BinaryBuilder {
Map<String, Source> uriToSource = <String, Source>{};
for (int i = 0; i < length; ++i) {
String uri = _sourceUriTable[i];
- String sourceCode = readStringEntry();
+ List<int> sourceCode = readUtf8Bytes();
int lineCount = readUInt();
List<int> lineStarts = new List<int>(lineCount);
int previousLineStart = 0;
« no previous file with comments | « pkg/kernel/lib/ast.dart ('k') | pkg/kernel/lib/binary/ast_to_binary.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698