Memory file system returns Uint8List from readAsBytes
Before this CL the memory file system would return a list - not a
Uint8List - when answering `readAsBytes`.
This for instance caused the ~5.5MB kernel platform file to take up
~42.5 MB of memory (at least on a 64 bit linux system).
This CL changes that to return a Uint8List, saving ~37 MB of memory
when using the kernel platform file, as for instance done when running a
dart file with the VM.
Change-Id: I5e44c342c89e6293684614c1d0b357cc3a4936d6
Reviewed-on: https://dart-review.googlesource.com/63949
Reviewed-by: Peter von der Ahé <ahe@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
diff --git a/pkg/front_end/lib/src/api_prototype/memory_file_system.dart b/pkg/front_end/lib/src/api_prototype/memory_file_system.dart
index 45bec4f..68f8ca8 100644
--- a/pkg/front_end/lib/src/api_prototype/memory_file_system.dart
+++ b/pkg/front_end/lib/src/api_prototype/memory_file_system.dart
@@ -86,11 +86,11 @@
@override
Future<List<int>> readAsBytes() async {
- List<int> contents = _fileSystem._files[uri];
+ Uint8List contents = _fileSystem._files[uri];
if (contents == null) {
throw new FileSystemException(uri, 'File $uri does not exist.');
}
- return contents.toList();
+ return new Uint8List.fromList(contents);
}
@override