| 84 | } |
| 85 | |
| 86 | const char* GetVarint32PtrFallback(const char* p, const char* limit, |
| 87 | uint32_t* value) { |
| 88 | uint32_t result = 0; |
| 89 | for (uint32_t shift = 0; shift <= 28 && p < limit; shift += 7) { |
| 90 | uint32_t byte = *(reinterpret_cast<const uint8_t*>(p)); |
| 91 | p++; |
| 92 | if (byte & 128) { |
| 93 | // More bytes are present |
| 94 | result |= ((byte & 127) << shift); |
| 95 | } else { |
| 96 | result |= (byte << shift); |
| 97 | *value = result; |
| 98 | return reinterpret_cast<const char*>(p); |
| 99 | } |
| 100 | } |
| 101 | return nullptr; |
| 102 | } |
| 103 | |
| 104 | bool GetVarint32(Slice* input, uint32_t* value) { |
| 105 | const char* p = input->data(); |