EncodePackedInt64 writes a list of 64-bit 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)
| 156 | // This operation is O(n^2) because we have to traverse the list of values to calculate the total |
| 157 | // encoded size and write that size *before* the actual encoded values. |
| 158 | func (e *Encoder) EncodePackedInt64(tag int, vs []int64) { |
| 159 | if len(vs) == 0 { |
| 160 | return |
| 161 | } |
| 162 | e.offset += EncodeTag(e.p[e.offset:], tag, WireTypeLengthDelimited) |
| 163 | sz := 0 |
| 164 | for _, v := range vs { |
| 165 | sz += SizeOfVarint(uint64(v)) |
| 166 | } |
| 167 | e.offset += EncodeVarint(e.p[e.offset:], uint64(sz)) |
| 168 | for _, v := range vs { |
| 169 | e.offset += EncodeVarint(e.p[e.offset:], uint64(v)) |
| 170 | } |
| 171 | } |
| 172 | |
| 173 | // EncodePackedUInt32 writes a list of 32-bit unsigned integers to the buffer using packed encoding, |
| 174 | // preceded by the varint-encoded tag key. |