mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 15:42:20 +00:00
Redo "[kernel] Create Source.sourceCode as view of the binary bytes"
Retrying now that https://github.com/dart-lang/sdk/issues/50206 is fixed. Change-Id: I2612e53c845b2e906ab51bfe39db2fe775e10bca Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/264602 Reviewed-by: Sigmund Cherem <sigmund@google.com> Commit-Queue: Stephen Adams <sra@google.com>
This commit is contained in:
parent
a4294c354c
commit
b03b9c3712
|
@ -244,6 +244,18 @@ class BinaryBuilder {
|
|||
return readBytes(readUInt30());
|
||||
}
|
||||
|
||||
Uint8List readOrViewByteList() {
|
||||
int length = readUInt30();
|
||||
List<int> source = _bytes;
|
||||
if (source is Uint8List) {
|
||||
Uint8List view =
|
||||
source.buffer.asUint8List(source.offsetInBytes + _byteOffset, length);
|
||||
_byteOffset += length;
|
||||
return view;
|
||||
}
|
||||
return readBytes(length);
|
||||
}
|
||||
|
||||
String readString() {
|
||||
return readStringEntry(readUInt30());
|
||||
}
|
||||
|
@ -927,7 +939,7 @@ class BinaryBuilder {
|
|||
String uriString = readString();
|
||||
Uri uri = Uri.parse(uriString);
|
||||
_sourceUriTable[i] = uri;
|
||||
Uint8List sourceCode = readByteList();
|
||||
Uint8List sourceCode = readOrViewByteList();
|
||||
int lineCount = readUInt30();
|
||||
List<int> lineStarts = new List<int>.filled(
|
||||
lineCount,
|
||||
|
|
Loading…
Reference in a new issue