From b76b1f7fa567e86c5d89b15df9a980d9c8ec8a75 Mon Sep 17 00:00:00 2001 From: Nikolas Rimikis Date: Mon, 20 Nov 2023 09:48:17 +0100 Subject: [PATCH] perf(dynamite_runtime): improve the performance of collecting bytes Signed-off-by: Nikolas Rimikis --- .../dynamite/dynamite_runtime/lib/src/http_extensions.dart | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/dynamite/dynamite_runtime/lib/src/http_extensions.dart b/packages/dynamite/dynamite_runtime/lib/src/http_extensions.dart index 6da979cc..0224edb8 100644 --- a/packages/dynamite/dynamite_runtime/lib/src/http_extensions.dart +++ b/packages/dynamite/dynamite_runtime/lib/src/http_extensions.dart @@ -18,9 +18,12 @@ final _xmlBytesConverter = /// Extension on byte streams that enable efficient transformations. extension BytesStreamExtension on BytesStream { - /// Returns the all bytes of the stream. + /// Collects all bytes from this stream into one Uint8List. + /// + /// The collector will assume that the bytes in this stream will not change. + /// See [BytesBuilder] for further information. Future get bytes async { - final buffer = BytesBuilder(); + final buffer = BytesBuilder(copy: false); await forEach(buffer.add);