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

Function EncodeZigZag32

encoder.go:433–436  ·  view source on GitHub ↗

EncodeZigZag32 encodes v into dest using the Protobuf zig/zag encoding for more efficient encoding of negative numbers, and returns the number of bytes written.

(dest []byte, v int32)

Source from the content-addressed store, hash-verified

431// EncodeZigZag32 encodes v into dest using the Protobuf zig/zag encoding for more efficient encoding
432// of negative numbers, and returns the number of bytes written.
433func EncodeZigZag32(dest []byte, v int32) int {
434 zz := uint64((uint32(v) << 1) ^ uint32((v >> 31)))
435 return EncodeVarint(dest, zz)
436}
437
438// EncodeZigZag64 encodes v into dest using the Protobuf zig/zag encoding for more efficient encoding
439// of negative numbers, and returns the number of bytes written.

Callers 2

EncodeSInt32Method · 0.85
EncodePackedSInt32Method · 0.85

Calls 1

EncodeVarintFunction · 0.85

Tested by

no test coverage detected