| 145 | } |
| 146 | |
| 147 | const char* GetVarint32PtrFallback(const char* p, const char* limit, |
| 148 | uint32* value) { |
| 149 | uint32 result = 0; |
| 150 | for (uint32 shift = 0; shift <= 28 && p < limit; shift += 7) { |
| 151 | uint32 byte = *(reinterpret_cast<const unsigned char*>(p)); |
| 152 | p++; |
| 153 | if (byte & 128) { |
| 154 | // More bytes are present |
| 155 | result |= ((byte & 127) << shift); |
| 156 | } else { |
| 157 | result |= (byte << shift); |
| 158 | *value = result; |
| 159 | return reinterpret_cast<const char*>(p); |
| 160 | } |
| 161 | } |
| 162 | return nullptr; |
| 163 | } |
| 164 | |
| 165 | bool GetVarint32(StringPiece* input, uint32* value) { |
| 166 | const char* p = input->data(); |