MCPcopy Create free account
hub / github.com/comaps/comaps / ReadVarInt64Array

Function ReadVarInt64Array

libs/coding/varint.hpp:229–263  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

227
228template <typename ConverterT, typename F, class WhileConditionT>
229void const * ReadVarInt64Array(void const * pBeg, WhileConditionT whileCondition, F f, ConverterT converter)
230{
231 uint8_t const * const pBegChar = static_cast<uint8_t const *>(pBeg);
232 uint64_t res64 = 0;
233 uint32_t res32 = 0;
234 uint32_t count32 = 0;
235 uint32_t count64 = 0;
236 uint8_t const * p = pBegChar;
237 while (whileCondition.Continue(p))
238 {
239 uint8_t const t = *p++;
240 res32 += (static_cast<uint32_t>(t & 127) << count32);
241 count32 += 7;
242 if (!(t & 128))
243 {
244 f(converter((static_cast<uint64_t>(res32) << count64) + res64));
245 whileCondition.NextVarInt();
246 res64 = 0;
247 res32 = 0;
248 count32 = 0;
249 count64 = 0;
250 }
251 else if (count32 == 28)
252 {
253 res64 += (static_cast<uint64_t>(res32) << count64);
254 res32 = 0;
255 count32 = 0;
256 count64 += 28;
257 }
258 }
259 ASSERT(count32 == 0 && res32 == 0 && res64 == 0, (res64, res32, count32));
260 if (count32 != 0)
261 MYTHROW(ReadVarIntException, ());
262 return p;
263}
264
265} // namespace impl
266

Callers 2

ReadVarUint64ArrayFunction · 0.85
UNIT_TESTFunction · 0.85

Calls 5

ASSERTFunction · 0.85
ContinueMethod · 0.45
NextVarIntMethod · 0.45

Tested by 1

UNIT_TESTFunction · 0.68