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

Method EncodePackedInt64

encoder.go:158–171  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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

Callers 7

TestEncodePackedInt64Function · 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

TestEncodePackedInt64Function · 0.76