@@ -14,16 +14,16 @@ import 'package:typed_data/typed_buffers.dart' show Uint8Buffer;
14
14
/// The byte order of serialized data is [Endianness.BIG_ENDIAN] .
15
15
/// The byte order of deserialized data is [Endianness.HOST_ENDIAN] .
16
16
class WriteBuffer {
17
- Uint8Buffer _buffer;
18
- ByteData _eightBytes;
19
- Uint8List _eightBytesAsList;
20
-
21
17
WriteBuffer () {
22
18
_buffer = new Uint8Buffer ();
23
19
_eightBytes = new ByteData (8 );
24
20
_eightBytesAsList = _eightBytes.buffer.asUint8List ();
25
21
}
26
22
23
+ Uint8Buffer _buffer;
24
+ ByteData _eightBytes;
25
+ Uint8List _eightBytesAsList;
26
+
27
27
void putUint8 (int byte) {
28
28
_buffer.add (byte);
29
29
}
@@ -60,9 +60,8 @@ class WriteBuffer {
60
60
if (Endianness .HOST_ENDIAN == Endianness .BIG_ENDIAN ) {
61
61
_buffer.addAll (list.buffer.asUint8List (list.offsetInBytes, 4 * list.length));
62
62
} else {
63
- for (final int value in list) {
63
+ for (final int value in list)
64
64
putInt32 (value);
65
- }
66
65
}
67
66
}
68
67
@@ -71,9 +70,8 @@ class WriteBuffer {
71
70
if (Endianness .HOST_ENDIAN == Endianness .BIG_ENDIAN ) {
72
71
_buffer.addAll (list.buffer.asUint8List (list.offsetInBytes, 8 * list.length));
73
72
} else {
74
- for (final int value in list) {
73
+ for (final int value in list)
75
74
putInt64 (value);
76
- }
77
75
}
78
76
}
79
77
@@ -82,18 +80,16 @@ class WriteBuffer {
82
80
if (Endianness .HOST_ENDIAN == Endianness .BIG_ENDIAN ) {
83
81
_buffer.addAll (list.buffer.asUint8List (list.offsetInBytes, 8 * list.length));
84
82
} else {
85
- for (final double value in list) {
83
+ for (final double value in list)
86
84
putFloat64 (value);
87
- }
88
85
}
89
86
}
90
87
91
88
void _alignTo (int alignment) {
92
89
final int mod = _buffer.length % alignment;
93
90
if (mod != 0 ) {
94
- for (int i = 0 ; i < alignment - mod; i++ ) {
91
+ for (int i = 0 ; i < alignment - mod; i++ )
95
92
_buffer.add (0 );
96
- }
97
93
}
98
94
}
99
95
@@ -152,9 +148,8 @@ class ReadBuffer {
152
148
list = data.buffer.asInt32List (data.offsetInBytes + position, length);
153
149
} else {
154
150
final ByteData invertedData = new ByteData (4 * length);
155
- for (int i = 0 ; i < length; i++ ) {
151
+ for (int i = 0 ; i < length; i++ )
156
152
invertedData.setInt32 (i * 4 , data.getInt32 (position + i * 4 , Endianness .HOST_ENDIAN ));
157
- }
158
153
list = new Int32List .view (invertedData.buffer);
159
154
}
160
155
position += 4 * length;
@@ -168,9 +163,8 @@ class ReadBuffer {
168
163
list = data.buffer.asInt64List (data.offsetInBytes + position, length);
169
164
} else {
170
165
final ByteData invertedData = new ByteData (8 * length);
171
- for (int i = 0 ; i < length; i++ ) {
166
+ for (int i = 0 ; i < length; i++ )
172
167
invertedData.setInt64 (i * 8 , data.getInt64 (position + i * 8 , Endianness .HOST_ENDIAN ));
173
- }
174
168
list = new Int64List .view (invertedData.buffer);
175
169
}
176
170
position += 8 * length;
@@ -184,9 +178,8 @@ class ReadBuffer {
184
178
list = data.buffer.asFloat64List (data.offsetInBytes + position, length);
185
179
} else {
186
180
final ByteData invertedData = new ByteData (8 * length);
187
- for (int i = 0 ; i < length; i++ ) {
181
+ for (int i = 0 ; i < length; i++ )
188
182
invertedData.setFloat64 (i * 8 , data.getFloat64 (position + i * 8 , Endianness .HOST_ENDIAN ));
189
- }
190
183
list = new Float64List .view (invertedData.buffer);
191
184
}
192
185
position += 8 * length;
@@ -195,9 +188,8 @@ class ReadBuffer {
195
188
196
189
void _alignTo (int alignment) {
197
190
final int mod = position % alignment;
198
- if (mod != 0 ) {
191
+ if (mod != 0 )
199
192
position += alignment - mod;
200
- }
201
193
}
202
194
203
195
bool get hasRemaining => position < data.lengthInBytes;
0 commit comments