mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 00:13:50 +00:00
[kernel] Create Source.sourceCode as view of the binary bytes
This saves about 400MB heap when loading a 900MB .dill file. Change-Id: I5a09b06764cb493aab8dade2afb4665e12688133 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/255802 Reviewed-by: Jens Johansen <jensj@google.com> Commit-Queue: Stephen Adams <sra@google.com>
This commit is contained in:
parent
7b704a727c
commit
a07a0333c3
|
@ -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