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

Method EncodePackedSInt64

encoder.go:238–251  ·  view source on GitHub ↗

EncodePackedSInt64 writes a list of 64-bit signed 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

236// This operation is O(n^2) because we have to traverse the list of values to calculate the total
237// encoded size and write that size *before* the actual encoded values.
238func (e *Encoder) EncodePackedSInt64(tag int, vs []int64) {
239 if len(vs) == 0 {
240 return
241 }
242 e.offset += EncodeTag(e.p[e.offset:], tag, WireTypeLengthDelimited)
243 sz := 0
244 for _, v := range vs {
245 sz += SizeOfZigZag(uint64(v))
246 }
247 e.offset += EncodeVarint(e.p[e.offset:], uint64(sz))
248 for _, v := range vs {
249 e.offset += EncodeZigZag64(e.p[e.offset:], v)
250 }
251}
252
253// EncodePackedFixed32 writes a list of 32-bit fixed-width unsigned integers to the buffer using packed
254// encoding, preceded by the varint-encoded tag key.

Callers 7

TestEncodePackedSInt64Function · 0.95
MarshalToMethod · 0.80
MarshalToMethod · 0.80
MarshalToMethod · 0.80
MarshalToMethod · 0.80
MarshalToMethod · 0.80
MarshalToMethod · 0.80

Calls 4

EncodeTagFunction · 0.85
SizeOfZigZagFunction · 0.85
EncodeVarintFunction · 0.85
EncodeZigZag64Function · 0.85

Tested by 1

TestEncodePackedSInt64Function · 0.76