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

Method EncodePackedSInt32

encoder.go:218–231  ·  view source on GitHub ↗

EncodePackedSInt32 writes a list of 32-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 []int32)

Source from the content-addressed store, hash-verified

216// This operation is O(n^2) because we have to traverse the list of values to calculate the total
217// encoded size and write that size *before* the actual encoded values.
218func (e *Encoder) EncodePackedSInt32(tag int, vs []int32) {
219 if len(vs) == 0 {
220 return
221 }
222 e.offset += EncodeTag(e.p[e.offset:], tag, WireTypeLengthDelimited)
223 sz := 0
224 for _, v := range vs {
225 sz += SizeOfZigZag(uint64(v))
226 }
227 e.offset += EncodeVarint(e.p[e.offset:], uint64(sz))
228 for _, v := range vs {
229 e.offset += EncodeZigZag32(e.p[e.offset:], v)
230 }
231}
232
233// EncodePackedSInt64 writes a list of 64-bit signed integers to the buffer using packed encoding,
234// preceded by the varint-encoded tag key.

Callers 7

TestEncodePackedSInt32Function · 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
EncodeZigZag32Function · 0.85

Tested by 1

TestEncodePackedSInt32Function · 0.76