As the spec states:
If an object can be represented in multiple possible output formats, serializers SHOULD use the format which represents the data in the smallest number of bytes.
should double and float be packed in the smallest way possible.
Currently double and floats are packed in full size. Even if they store the value 0. The following change would "fix" this issue for double.
template <typename Stream>
inline packer<Stream>& packer<Stream>::pack_double(double d)
{
if (d == int64_t(d))
{
pack_imp_int64(int64_t(d));
return *this;
}
union { double f; uint64_t i; } mem;
mem.f = d;
char buf[9];
buf[0] = static_cast<char>(0xcbu);
#if defined(TARGET_OS_IPHONE)
// ok
#elif defined(__arm__) && !(__ARM_EABI__) // arm-oabi
// https://github.com/msgpack/msgpack-perl/pull/1
mem.i = (mem.i & 0xFFFFFFFFUL) << 32UL | (mem.i >> 32UL);
#endif
_msgpack_store64(&buf[1], mem.i);
append_buffer(buf, 9);
return *this;
}
#1018
As the spec states:
should double and float be packed in the smallest way possible.
Currently double and floats are packed in full size. Even if they store the value 0. The following change would "fix" this issue for double.
#1018