Open afrind opened 4 weeks ago
FWIW - right now I'm just adding 16 bits of space and always encoding a 2 byte varint, and restricting my control msgs to 14 bits.
We could, but I'm not sure there's an advantage over your approach of only using 14 bits? For those who care about saving an extra byte, at least for some messages that are always short, they can use the 1 byte encoding.
Isn't this just as annoying for all the varints everywhere in the control message ? Just trying to get at if there is some reason this first one is particularly irritating?
It's very annoying to write a message serializer for the current messages. Doing it in two-passes (one to compute the length, one to serialize) is one option. Using some kind of buffer chaining is another. But do we need to? The control messages aren't large, so I don't think we need more than 64k for any single message. They also aren't so frequent that we need to shave a length byte for 64 byte messages. Using a fixed size length allows you to pin a placeholder, serialize the message, and write the actual length back.