EncodePackedUInt64 writes a list of 64-bit unsigned 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 value
(tag int, vs []uint64)
| 196 | // This operation is O(n^2) because we have to traverse the list of values to calculate the total |
| 197 | // encoded size and write that size *before* the actual encoded values. |
| 198 | func (e *Encoder) EncodePackedUInt64(tag int, vs []uint64) { |
| 199 | if len(vs) == 0 { |
| 200 | return |
| 201 | } |
| 202 | e.offset += EncodeTag(e.p[e.offset:], tag, WireTypeLengthDelimited) |
| 203 | sz := 0 |
| 204 | for _, v := range vs { |
| 205 | sz += SizeOfVarint(v) |
| 206 | } |
| 207 | e.offset += EncodeVarint(e.p[e.offset:], uint64(sz)) |
| 208 | for _, v := range vs { |
| 209 | e.offset += EncodeVarint(e.p[e.offset:], v) |
| 210 | } |
| 211 | } |
| 212 | |
| 213 | // EncodePackedSInt32 writes a list of 32-bit signed integers to the buffer using packed encoding, |
| 214 | // preceded by the varint-encoded tag key. |