Skip to content

Commit

Permalink
Use emplace_back() instead of push_back() to avoid temporary object
Browse files Browse the repository at this point in the history
  • Loading branch information
cgutman committed Jul 18, 2024
1 parent 109c9ef commit 026e9c4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ namespace stream {
shards_p[x] = (uint8_t *) next;
next += blocksize;

Check warning on line 669 in src/stream.cpp

View check run for this annotation

Codecov / codecov/patch

src/stream.cpp#L668-L669

Added lines #L668 - L669 were not covered by tests
}
payload_buffers.push_back({ std::begin(payload), aligned_data_shards * blocksize });
payload_buffers.emplace_back(std::begin(payload), aligned_data_shards * blocksize);

// If the last data shard needs to be zero-padded, we must use the shards buffer
if (pad) {
Expand All @@ -686,7 +686,7 @@ namespace stream {
}

// Add a payload buffer describing the shard buffer
payload_buffers.push_back(platf::buffer_descriptor_t { std::begin(shards), shards.size() });
payload_buffers.emplace_back(std::begin(shards), shards.size());

if (fecpercentage != 0) {
// Point into our allocated buffer for the parity shards
Expand Down

0 comments on commit 026e9c4

Please sign in to comment.