Store a single byte in a protobuf message

前端 未结 1 469
不思量自难忘°
不思量自难忘° 2021-01-21 14:03

What data type do I use to store a single byte in a protocol buffer message? Seeing the list at https://developers.google.com/protocol-buffers/docs/proto#scalar it seems like on

1条回答
  •  一生所求
    2021-01-21 14:56

    Well you need to understand that it will take at least two bytes anyway - one for the tag and one for the data. (The tag will take more space if the field number is high.) If you use uint32, it will take 1 byte for the data for values up to 127, and 2 bytes for anything larger.

    I don't believe there's anything that will be more efficient than that.

    0 讨论(0)
提交回复
热议问题