EncodePackedUInt32 writes a list of 32-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 []uint32)
| 176 | // This operation is O(n^2) because we have to traverse the list of values to calculate the total |
| 177 | // encoded size and write that size *before* the actual encoded values. |
| 178 | func (e *Encoder) EncodePackedUInt32(tag int, vs []uint32) { |
| 179 | if len(vs) == 0 { |
| 180 | return |
| 181 | } |
| 182 | e.offset += EncodeTag(e.p[e.offset:], tag, WireTypeLengthDelimited) |
| 183 | sz := 0 |
| 184 | for _, v := range vs { |
| 185 | sz += SizeOfVarint(uint64(v)) |
| 186 | } |
| 187 | e.offset += EncodeVarint(e.p[e.offset:], uint64(sz)) |
| 188 | for _, v := range vs { |
| 189 | e.offset += EncodeVarint(e.p[e.offset:], uint64(v)) |
| 190 | } |
| 191 | } |
| 192 | |
| 193 | // EncodePackedUInt64 writes a list of 64-bit unsigned integers to the buffer using packed encoding, |
| 194 | // preceded by the varint-encoded tag key. |