[api] Prefer make_unique_for_overwrite for noninit send buffers

Use C++20 std::make_unique_for_overwrite instead of std::make_unique
for the send buffer allocation in buffer_data_from_iov_. This skips
the unnecessary zero-initialization for POD types, since the buffer
is immediately and completely filled via memcpy from the iov segments
in the loop that follows.
This commit is contained in:
J. Nick Koston
2026-02-25 09:56:28 -07:00
parent 1beeb9ab5c
commit fdda6a5f5f

View File

@@ -134,7 +134,7 @@ void APIFrameHelper::buffer_data_from_iov_(const struct iovec *iov, int iovcnt,
uint16_t buffer_size = total_write_len - offset;
auto &buffer = this->tx_buf_[this->tx_buf_tail_];
buffer = std::make_unique<SendBuffer>(SendBuffer{
.data = std::make_unique<uint8_t[]>(buffer_size),
.data = std::make_unique_for_overwrite<uint8_t[]>(buffer_size),
.size = buffer_size,
.offset = 0,
});