mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-10-24 17:30:46 +02:00
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:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user