-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
backport improved byte consolidation to SyncTransformer and Backgroun…
…dTranformer (#2248) Follow up to #2239: The more efficient Stream<UintList> -> Uint8List conversion can be backported to `SyncTransformer` & the extending `BackgroundTransformer`
- Loading branch information
1 parent
4d310a2
commit fa043d4
Showing
4 changed files
with
45 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import 'dart:typed_data'; | ||
|
||
/// Consolidates a stream of [Uint8List] into a single [Uint8List] | ||
Future<Uint8List> consolidateBytes(Stream<Uint8List> stream) async { | ||
final builder = BytesBuilder(copy: false); | ||
|
||
await for (final chunk in stream) { | ||
builder.add(chunk); | ||
} | ||
|
||
return builder.takeBytes(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters