| 175 | } |
| 176 | |
| 177 | const char* GetVarint64Ptr(const char* p, const char* limit, uint64* value) { |
| 178 | uint64 result = 0; |
| 179 | for (uint32 shift = 0; shift <= 63 && p < limit; shift += 7) { |
| 180 | uint64 byte = *(reinterpret_cast<const unsigned char*>(p)); |
| 181 | p++; |
| 182 | if (byte & 128) { |
| 183 | // More bytes are present |
| 184 | result |= ((byte & 127) << shift); |
| 185 | } else { |
| 186 | result |= (byte << shift); |
| 187 | *value = result; |
| 188 | return reinterpret_cast<const char*>(p); |
| 189 | } |
| 190 | } |
| 191 | return nullptr; |
| 192 | } |
| 193 | |
| 194 | bool GetVarint64(StringPiece* input, uint64* value) { |
| 195 | const char* p = input->data(); |
no outgoing calls