mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Align doubles to 8 bytes in the StandardMessageCodec (#10758)
See https://github.com/flutter/flutter/issues/10701
This commit is contained in:
parent
3db402ec98
commit
6965312822
@ -1 +1 @@
|
||||
f741647d4977410ff8e2c02160eaa02bcb1f0a2b
|
||||
784e9756720f7f6daa15c95ba3df6215bb54783f
|
||||
|
@ -55,6 +55,7 @@ class WriteBuffer {
|
||||
|
||||
/// Write an Float64 into the buffer.
|
||||
void putFloat64(double value) {
|
||||
_alignTo(8);
|
||||
_eightBytes.setFloat64(0, value, Endianness.HOST_ENDIAN);
|
||||
_buffer.addAll(_eightBytesAsList);
|
||||
}
|
||||
@ -150,6 +151,7 @@ class ReadBuffer {
|
||||
|
||||
/// Reads a Float64 from the buffer.
|
||||
double getFloat64() {
|
||||
_alignTo(8);
|
||||
final double value = data.getFloat64(_position, Endianness.HOST_ENDIAN);
|
||||
_position += 8;
|
||||
return value;
|
||||
|
@ -177,6 +177,14 @@ void main() {
|
||||
];
|
||||
_checkEncodeDecode<dynamic>(standard, message);
|
||||
});
|
||||
test('should align doubles to 8 bytes', () {
|
||||
_checkEncoding<dynamic>(
|
||||
standard,
|
||||
1.0,
|
||||
<int>[6, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0xf0, 0x3f],
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user