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

Method appendBitsFresh

bolt/common/memory/ByteStream.h:330–347  ·  view source on GitHub ↗

A fast path for appending bits into pre-cleared buffers after first extend.

Source from the content-addressed store, hash-verified

328
329 // A fast path for appending bits into pre-cleared buffers after first extend.
330 inline void
331 appendBitsFresh(const uint64_t* bits, int32_t begin, int32_t end) {
332 const auto position = current_->position;
333 if (begin == 0 && end <= 56) {
334 const auto available = current_->size - position;
335 // There must be 8 bytes writable. If available is 56, there are 7, so >.
336 if (available > 56) {
337 const auto offset = position & 7;
338 uint64_t* buffer =
339 reinterpret_cast<uint64_t*>(current_->buffer + (position >> 3));
340 const auto mask = bits::lowMask(offset);
341 *buffer = (*buffer & mask) | (bits[0] << offset);
342 current_->position += end;
343 return;
344 }
345 }
346 appendBits(bits, begin, end);
347 }
348
349 // Writes 'bits' from bit positions begin..end to the current position of
350 // 'this'. Extends 'this' if writing past end.

Callers 2

appendNullsMethod · 0.80
TEST_FFunction · 0.80

Calls 1

lowMaskFunction · 0.85

Tested by

no test coverage detected