Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Declare a return value of Uint8List in BytesBuilder methods #58

Merged
merged 2 commits into from
May 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.0.13

* Internal changes for consistency with the Dart SDK.

## 1.0.12

* Allow `stream_channel` version 2.x
Expand Down
12 changes: 6 additions & 6 deletions lib/src/copy/bytes_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ abstract class BytesBuilder {
///
/// The list returned is a view of the internal buffer, limited to the
/// [length].
List<int> takeBytes();
Uint8List takeBytes();

/// Returns a copy of the current contents of the builder.
///
/// Leaves the contents of the builder intact.
List<int> toBytes();
Uint8List toBytes();

/// The number of bytes in the builder.
int get length;
Expand Down Expand Up @@ -124,14 +124,14 @@ class _CopyingBytesBuilder implements BytesBuilder {
_buffer = newBuffer;
}

List<int> takeBytes() {
Uint8List takeBytes() {
if (_length == 0) return _emptyList;
var buffer = Uint8List.view(_buffer.buffer, 0, _length);
clear();
return buffer;
}

List<int> toBytes() {
Uint8List toBytes() {
if (_length == 0) return _emptyList;
return Uint8List.fromList(Uint8List.view(_buffer.buffer, 0, _length));
}
Expand Down Expand Up @@ -179,7 +179,7 @@ class _BytesBuilder implements BytesBuilder {
_length++;
}

List<int> takeBytes() {
Uint8List takeBytes() {
if (_length == 0) return _CopyingBytesBuilder._emptyList;
if (_chunks.length == 1) {
var buffer = _chunks[0];
Expand All @@ -196,7 +196,7 @@ class _BytesBuilder implements BytesBuilder {
return buffer;
}

List<int> toBytes() {
Uint8List toBytes() {
if (_length == 0) return _CopyingBytesBuilder._emptyList;
var buffer = Uint8List(_length);
int offset = 0;
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: web_socket_channel
version: 1.0.12
version: 1.0.13

description: >-
StreamChannel wrappers for WebSockets. Provides a cross-platform
Expand Down