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

Unified Diff: sdk/lib/io/file_impl.dart

Issue 18031023: Remove _BufferList from dart:io and now use BytesBuilder. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Use takeBytes not toBytes. Created 7 years, 5 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
Index: sdk/lib/io/file_impl.dart
diff --git a/sdk/lib/io/file_impl.dart b/sdk/lib/io/file_impl.dart
index e9403c2ae0fb9ac5b7cfc63f2b129ef85a863c5a..078999024b75f798800ff7b1ef9b981865a35879 100644
--- a/sdk/lib/io/file_impl.dart
+++ b/sdk/lib/io/file_impl.dart
@@ -479,12 +479,11 @@ class _File implements File {
Future<List<int>> readAsBytes() {
_ensureFileService();
Completer<List<int>> completer = new Completer<List<int>>();
- var chunks = new _BufferList();
+ var builder = new BytesBuilder();
openRead().listen(
- (d) => chunks.add(d),
+ (d) => builder.add(d),
onDone: () {
- var result = chunks.readBytes();
- completer.complete(result);
+ completer.complete(builder.takeBytes());
},
onError: (e) {
completer.completeError(e);
@@ -495,13 +494,13 @@ class _File implements File {
List<int> readAsBytesSync() {
var opened = openSync();
- var chunks = new _BufferList();
+ var builder = new BytesBuilder();
var data;
while ((data = opened.readSync(_BLOCK_SIZE)).length > 0) {
- chunks.add(data);
+ builder.add(data);
}
opened.closeSync();
- return chunks.readBytes();
+ return builder.takeBytes();
}
Future<String> readAsString({Encoding encoding: Encoding.UTF_8}) {

Powered by Google App Engine
This is Rietveld 408576698