EncodePackedSInt64 writes a list of 64-bit signed integers to the buffer using packed encoding, preceded by the varint-encoded tag key. This operation is O(n^2) because we have to traverse the list of values to calculate the total encoded size and write that size *before* the actual encoded values.
(tag int, vs []int64)
| 236 | // This operation is O(n^2) because we have to traverse the list of values to calculate the total |
| 237 | // encoded size and write that size *before* the actual encoded values. |
| 238 | func (e *Encoder) EncodePackedSInt64(tag int, vs []int64) { |
| 239 | if len(vs) == 0 { |
| 240 | return |
| 241 | } |
| 242 | e.offset += EncodeTag(e.p[e.offset:], tag, WireTypeLengthDelimited) |
| 243 | sz := 0 |
| 244 | for _, v := range vs { |
| 245 | sz += SizeOfZigZag(uint64(v)) |
| 246 | } |
| 247 | e.offset += EncodeVarint(e.p[e.offset:], uint64(sz)) |
| 248 | for _, v := range vs { |
| 249 | e.offset += EncodeZigZag64(e.p[e.offset:], v) |
| 250 | } |
| 251 | } |
| 252 | |
| 253 | // EncodePackedFixed32 writes a list of 32-bit fixed-width unsigned integers to the buffer using packed |
| 254 | // encoding, preceded by the varint-encoded tag key. |