| 128 | } |
| 129 | |
| 130 | Byte* ByteBuffer::appendWritable(size_t size) { |
| 131 | if (size == 0) { |
| 132 | return _data + _size; |
| 133 | } |
| 134 | |
| 135 | auto nextSize = _size + size; |
| 136 | if (nextSize > _capacity) { |
| 137 | reallocate( |
| 138 | std::max(static_cast<size_t>(nextPowerOfTwo(static_cast<unsigned long>(nextSize))), kMinAllocationSize)); |
| 139 | } |
| 140 | |
| 141 | auto* ptr = _data + _size; |
| 142 | _size = nextSize; |
| 143 | return ptr; |
| 144 | } |
| 145 | |
| 146 | void ByteBuffer::append(const Byte* begin, const Byte* end) { |
| 147 | auto size = static_cast<size_t>(end - begin); |