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

Unified Diff: pkg/http/lib/src/byte_stream.dart

Issue 47923022: Use BytesBuilder in pkg:http, when accumulating binary data. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 1 month 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/http/lib/src/byte_stream.dart
diff --git a/pkg/http/lib/src/byte_stream.dart b/pkg/http/lib/src/byte_stream.dart
index c75654a28e9b656dc5877582904d289f472179ef..a15475745d5cc048fc196902ebbdbd200724e958 100644
--- a/pkg/http/lib/src/byte_stream.dart
+++ b/pkg/http/lib/src/byte_stream.dart
@@ -23,11 +23,8 @@ class ByteStream extends StreamView<List<int>> {
/// Collects the data of this stream in a [Uint8List].
Future<Uint8List> toBytes() {
- /// TODO(nweiz): use BufferList when issue 6409 is fixed.
- return fold(<int>[], (buffer, chunk) {
- buffer.addAll(chunk);
- return buffer;
- }).then(toUint8List);
+ return fold(new BytesBuilder(), (builder, chunk) => builder..add(chunk))
+ .then((builder) => builder.takeBytes());
nweiz 2013/11/01 18:31:19 Indent this two more spaces.
Anders Johnsen 2013/11/04 07:13:34 Done: https://codereview.chromium.org/57653002
}
/// Collect the data of this stream in a [String], decoded according to
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698