Skip to content

Commit

Permalink
rpc: Emplace buffers into vector, not push
Browse files Browse the repository at this point in the history
There are two places that accumulate a vector of buffer and for that
they push-back the temporarily-constructed one. There's the emplace_back
shortcut for such cases.

Signed-off-by: Pavel Emelyanov <[email protected]>
  • Loading branch information
xemul committed Oct 30, 2024
1 parent fba36a3 commit ccca5b3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/rpc/rpc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ namespace rpc {
std::vector<temporary_buffer<char>> v;
v.reserve(align_up(size_t(size), chunk_size) / chunk_size);
while (size_) {
v.push_back(temporary_buffer<char>(std::min(chunk_size, size_)));
v.emplace_back(std::min(chunk_size, size_));
size_ -= v.back().size();
}
bufs = std::move(v);
Expand Down Expand Up @@ -88,7 +88,7 @@ namespace rpc {
newbufs.reserve(orgbufs.size());
deleter d = make_object_deleter(std::move(org));
for (auto&& b : orgbufs) {
newbufs.push_back(temporary_buffer<char>(b.get_write(), b.size(), d.share()));
newbufs.emplace_back(b.get_write(), b.size(), d.share());
}
buf.bufs = std::move(newbufs);
}
Expand Down

0 comments on commit ccca5b3

Please sign in to comment.