| 114 | } |
| 115 | |
| 116 | const char* GetVarint64Ptr(const char* p, const char* limit, uint64_t* value) { |
| 117 | uint64_t result = 0; |
| 118 | for (uint32_t shift = 0; shift <= 63 && p < limit; shift += 7) { |
| 119 | uint64_t byte = *(reinterpret_cast<const uint8_t*>(p)); |
| 120 | p++; |
| 121 | if (byte & 128) { |
| 122 | // More bytes are present |
| 123 | result |= ((byte & 127) << shift); |
| 124 | } else { |
| 125 | result |= (byte << shift); |
| 126 | *value = result; |
| 127 | return reinterpret_cast<const char*>(p); |
| 128 | } |
| 129 | } |
| 130 | return nullptr; |
| 131 | } |
| 132 | |
| 133 | bool GetVarint64(Slice* input, uint64_t* value) { |
| 134 | const char* p = input->data(); |
no outgoing calls