diff --git a/be/src/util/coding.h b/be/src/util/coding.h index 714c68abaa4ea3..57e839f6d1ecd7 100644 --- a/be/src/util/coding.h +++ b/be/src/util/coding.h @@ -143,7 +143,10 @@ extern uint8_t* encode_varint64(uint8_t* dst, uint64_t value); inline uint8_t* encode_varint64(uint8_t* dst, uint64_t v) { static const unsigned int B = 128; while (v >= B) { - *(dst++) = (v & (B - 1)) | B; + // Fetch low seven bits from current v, and the eight bit is marked as compression mark. + // v | B is optimsed from (v & (B-1)) | B, because result is assgined to uint8_t and other bits + // is cleared by implicit conversion. + *(dst++) = v | B; v >>= 7; } *(dst++) = static_cast(v);