3 ms·
Very nice! Puts together many of my favorite protobuf techniques. I am glad that people do not feel that they are required to use generated code when they choos
by jeffbee 4y ago
Very nice! Puts together many of my favorite protobuf techniques. I am glad that people do not feel that they are required to use generated code when they choose the protobuf format.
One thing I will quibble about is the representation of the tag number 19, named SrcCountry. The author shows it as binary 10011010 but this is impossible because protobuf tags are themselves encoded as continuation bit variable-length numbers and cannot end in a byte with the most significant bit set. That's why fields 1-15 are the magic fast-path fields taking only 1 byte. Field 19 would need two bytes... 10000001_00011010 or in hex 81 1A
- vbernat 4y agoAuthor here. The tag is shown not encoded as a variable int (I admit this is not super clear). Its encoded version is 0x9a 0x01. I think this is correct. This the result of (19 << 3) + 2 encoded as a varint.
- jeffbee 4y agoOh I see, the thing on the left is logical and the thing on the right is on the wire. Thanks for helping me read it.