Skip to content

msgpack optimization. #1131

@MrCoInSanity

Description

@MrCoInSanity

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
    }
}
    

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions