A fast path for appending bits into pre-cleared buffers after first extend.
| 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. |
no test coverage detected