@@ -26,9 +26,9 @@ abstract class BytesBuilder {
26
26
/// output. Default is `true` .
27
27
factory BytesBuilder ({bool copy: true }) {
28
28
if (copy) {
29
- return new _CopyingBytesBuilder ();
29
+ return _CopyingBytesBuilder ();
30
30
} else {
31
- return new _BytesBuilder ();
31
+ return _BytesBuilder ();
32
32
}
33
33
}
34
34
@@ -71,15 +71,15 @@ class _CopyingBytesBuilder implements BytesBuilder {
71
71
// Start with 1024 bytes.
72
72
static const int _INIT_SIZE = 1024 ;
73
73
74
- static final _emptyList = new Uint8List (0 );
74
+ static final _emptyList = Uint8List (0 );
75
75
76
76
int _length = 0 ;
77
77
Uint8List _buffer;
78
78
79
79
_CopyingBytesBuilder ([int initialCapacity = 0 ])
80
80
: _buffer = (initialCapacity <= 0 )
81
81
? _emptyList
82
- : new Uint8List (_pow2roundup (initialCapacity));
82
+ : Uint8List (_pow2roundup (initialCapacity));
83
83
84
84
void add (List <int > bytes) {
85
85
int bytesLength = bytes.length;
@@ -119,22 +119,21 @@ class _CopyingBytesBuilder implements BytesBuilder {
119
119
} else {
120
120
newSize = _pow2roundup (newSize);
121
121
}
122
- var newBuffer = new Uint8List (newSize);
122
+ var newBuffer = Uint8List (newSize);
123
123
newBuffer.setRange (0 , _buffer.length, _buffer);
124
124
_buffer = newBuffer;
125
125
}
126
126
127
127
List <int > takeBytes () {
128
128
if (_length == 0 ) return _emptyList;
129
- var buffer = new Uint8List .view (_buffer.buffer, 0 , _length);
129
+ var buffer = Uint8List .view (_buffer.buffer, 0 , _length);
130
130
clear ();
131
131
return buffer;
132
132
}
133
133
134
134
List <int > toBytes () {
135
135
if (_length == 0 ) return _emptyList;
136
- return new Uint8List .fromList (
137
- new Uint8List .view (_buffer.buffer, 0 , _length));
136
+ return Uint8List .fromList (Uint8List .view (_buffer.buffer, 0 , _length));
138
137
}
139
138
140
139
int get length => _length;
@@ -169,14 +168,14 @@ class _BytesBuilder implements BytesBuilder {
169
168
if (bytes is Uint8List ) {
170
169
typedBytes = bytes;
171
170
} else {
172
- typedBytes = new Uint8List .fromList (bytes);
171
+ typedBytes = Uint8List .fromList (bytes);
173
172
}
174
173
_chunks.add (typedBytes);
175
174
_length += typedBytes.length;
176
175
}
177
176
178
177
void addByte (int byte) {
179
- _chunks.add (new Uint8List (1 )..[0 ] = byte);
178
+ _chunks.add (Uint8List (1 )..[0 ] = byte);
180
179
_length++ ;
181
180
}
182
181
@@ -187,7 +186,7 @@ class _BytesBuilder implements BytesBuilder {
187
186
clear ();
188
187
return buffer;
189
188
}
190
- var buffer = new Uint8List (_length);
189
+ var buffer = Uint8List (_length);
191
190
int offset = 0 ;
192
191
for (var chunk in _chunks) {
193
192
buffer.setRange (offset, offset + chunk.length, chunk);
@@ -199,7 +198,7 @@ class _BytesBuilder implements BytesBuilder {
199
198
200
199
List <int > toBytes () {
201
200
if (_length == 0 ) return _CopyingBytesBuilder ._emptyList;
202
- var buffer = new Uint8List (_length);
201
+ var buffer = Uint8List (_length);
203
202
int offset = 0 ;
204
203
for (var chunk in _chunks) {
205
204
buffer.setRange (offset, offset + chunk.length, chunk);
0 commit comments