MCPcopy Create free account
hub / github.com/bytedance/bolt / decode128FromByteSource

Method decode128FromByteSource

bolt/common/encode/Coding.h:246–275  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

244 return val;
245 }
246 static UInt128 decode128FromByteSource(strings::ByteSource* src) {
247 UInt128 val = 0;
248 int32_t shift = 0;
249 int32_t max_size = kMaxSize128;
250 folly::StringPiece chunk;
251 int32_t remaining = 0;
252 const char* p = nullptr;
253 for (;;) {
254 if (remaining == 0) {
255 CHECK(src->next(&chunk));
256 p = chunk.start();
257 remaining = chunk.size();
258 DCHECK_GT(remaining, 0);
259 }
260 --remaining;
261 if (*p & 0x80) {
262 CHECK_GT(max_size, 1); // We must have room for the last byte, too
263 --max_size;
264 val |= UInt128(*p++ & 0x7f) << shift;
265 shift += 7;
266 } else {
267 val |= UInt128(*p++) << shift;
268 break;
269 }
270 }
271 if (remaining) {
272 src->backUp(remaining);
273 }
274 return val;
275 }
276};
277
278// Zig-zag encoding that maps signed integers with a small absolute value

Callers

nothing calls this directly

Calls 5

UInt128Class · 0.85
backUpMethod · 0.80
nextMethod · 0.45
startMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected