github-actions[bot] commented on code in PR #17112:
URL: https://github.com/apache/doris/pull/17112#discussion_r1123227716
##########
be/src/util/bit_stream_utils.inline.h:
##########
@@ -195,17 +208,48 @@ inline bool BitReader::GetAligned(int num_bytes, T* v) {
return true;
}
-inline bool BitReader::GetVlqInt(int32_t* v) {
- *v = 0;
- int shift = 0;
- int num_bytes = 0;
- uint8_t byte = 0;
- do {
+inline bool BitReader::GetVlqInt(uint32_t* v) {
+ uint32_t tmp = 0;
+ for (int num_bytes = 0; num_bytes < MAX_VLQ_BYTE_LEN; num_bytes++) {
+ uint8_t byte = 0;
if (!GetAligned<uint8_t>(1, &byte)) return false;
- *v |= (byte & 0x7F) << shift;
- shift += 7;
- DCHECK_LE(++num_bytes, MAX_VLQ_BYTE_LEN);
- } while ((byte & 0x80) != 0);
+ tmp |= static_cast<uint32_t>(byte & 0x7F) << (7 * num_bytes);
+ if ((byte & 0x80) == 0) {
+ *v = tmp;
+ return true;
+ }
+ }
+ return false;
+}
+
+inline bool BitReader::GetZigZagVlqInt(int32_t* v) {
+ uint32_t u;
+ if (!GetVlqInt(&u)) return false;
+ u = (u >> 1) ^ (~(u & 1) + 1);
+ // copy uint32_t to int32_t
+ std::memcpy(v, &u, sizeof(uint32_t));
+ return true;
+}
+
+inline bool BitReader::GetVlqInt(uint64_t* v) {
+ uint64_t tmp = 0;
+ for (int num_bytes = 0; num_bytes < MAX_VLQ_BYTE_LEN_FOR_INT64;
num_bytes++) {
+ uint8_t byte = 0;
+ if (!GetAligned<uint8_t>(1, &byte)) return false;
Review Comment:
warning: statement should be inside braces
[readability-braces-around-statements]
```suggestion
if (!GetAligned<uint8_t>(1, &byte)) { return false;
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]