|
|
|
@ -124,7 +124,7 @@ GPB_INLINE int64_t GPBLogicalRightShift64(int64_t value, int32_t spaces) { |
|
|
|
|
// negative values must be sign-extended to 64 bits to be varint encoded,
|
|
|
|
|
// thus always taking 10 bytes on the wire.)
|
|
|
|
|
GPB_INLINE int32_t GPBDecodeZigZag32(uint32_t n) { |
|
|
|
|
return (int32_t)(GPBLogicalRightShift32((int32_t)n, 1) ^ -((int32_t)(n)&1)); |
|
|
|
|
return (int32_t)(GPBLogicalRightShift32((int32_t)n, 1) ^ -((int32_t)(n) & 1)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Decode a ZigZag-encoded 64-bit value. ZigZag encodes signed integers
|
|
|
|
@ -132,7 +132,7 @@ GPB_INLINE int32_t GPBDecodeZigZag32(uint32_t n) { |
|
|
|
|
// negative values must be sign-extended to 64 bits to be varint encoded,
|
|
|
|
|
// thus always taking 10 bytes on the wire.)
|
|
|
|
|
GPB_INLINE int64_t GPBDecodeZigZag64(uint64_t n) { |
|
|
|
|
return (int64_t)(GPBLogicalRightShift64((int64_t)n, 1) ^ -((int64_t)(n)&1)); |
|
|
|
|
return (int64_t)(GPBLogicalRightShift64((int64_t)n, 1) ^ -((int64_t)(n) & 1)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Encode a ZigZag-encoded 32-bit value. ZigZag encodes signed integers
|
|
|
|
|