msgpack optimization.
Opened this issue · 0 comments
MrCoInSanity commented
So, first of all, thank you for making such a great library. I was wondering if you could give me your feedback on how I'm packing my data. I feel like there is a more efficient way to do it. My goal is pack the data as fast as possible because this is getting sent to a renderer. Here is my code below, I appreciate any feedback.
for (const auto& data : dataVector) {
msgpack_pack_array(pk, 2); // Pack each pair in an inner array
msgpack_pack_int(pk, static_cast<int>(data.type));
switch (data.type) {
case TYPE_Point:
msgpack_pack_array(pk, 7);
msgpack_pack_unsigned_short(pk, data.pointData.x);
msgpack_pack_unsigned_short(pk, data.pointData.y);
msgpack_pack_unsigned_short(pk, data.pointData.size);
msgpack_pack_unsigned_char(pk, data.pointData.thickness);
msgpack_pack_unsigned_char(pk, data.pointData.r);
msgpack_pack_unsigned_char(pk, data.pointData.g);
msgpack_pack_unsigned_char(pk, data.pointData.b);
break;
//more case statements
}
}