Set MSGPACK_ZONE_ALIGNOF(char) explicitly.

It makes efficient zone allocation.
If it was omitted, the default alignment was applied. It was inefficient.
This commit is contained in:
Takatoshi Kondo
2017-07-23 19:11:12 +09:00
parent 64baa15f8e
commit a0e4294b5a
9 changed files with 14 additions and 14 deletions

View File

@@ -79,7 +79,7 @@ struct object_with_zone<std::array<char, N>> {
void operator()(msgpack::object::with_zone& o, const std::array<char, N>& v) const {
uint32_t size = checked_get_container_size(v.size());
o.type = msgpack::type::BIN;
char* ptr = static_cast<char*>(o.zone.allocate_align(size));
char* ptr = static_cast<char*>(o.zone.allocate_align(size, MSGPACK_ZONE_ALIGNOF(char)));
o.via.bin.ptr = ptr;
o.via.bin.size = size;
std::memcpy(ptr, v.data(), size);

View File

@@ -79,7 +79,7 @@ struct object_with_zone<std::array<unsigned char, N>> {
void operator()(msgpack::object::with_zone& o, const std::array<unsigned char, N>& v) const {
uint32_t size = checked_get_container_size(v.size());
o.type = msgpack::type::BIN;
char* ptr = static_cast<char*>(o.zone.allocate_align(size));
char* ptr = static_cast<char*>(o.zone.allocate_align(size, MSGPACK_ZONE_ALIGNOF(char)));
o.via.bin.ptr = ptr;
o.via.bin.size = size;
std::memcpy(ptr, v.data(), size);