MCPcopy Create free account
hub / github.com/CrowdStrike/csproto / EncodePackedUInt64

Method EncodePackedUInt64

encoder.go:198–211  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
198func (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.

Callers 7

TestEncodePackedUInt64Function · 0.95
MarshalToMethod · 0.80
MarshalToMethod · 0.80
MarshalToMethod · 0.80
MarshalToMethod · 0.80
MarshalToMethod · 0.80
MarshalToMethod · 0.80

Calls 3

EncodeTagFunction · 0.85
SizeOfVarintFunction · 0.85
EncodeVarintFunction · 0.85

Tested by 1

TestEncodePackedUInt64Function · 0.76