Skip to content

Commit

Permalink
Improve generator performance by bypassing std::vector checks.
Browse files Browse the repository at this point in the history
  • Loading branch information
maxsharabayko authored Nov 26, 2024
1 parent 45eca3e commit 633eb69
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion xtransmit/metrics.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ namespace metrics
inline void generate_payload(vector<char>& payload)
{
const int seqno = m_seqno++;
iota(payload.begin(), payload.end(), static_cast<char>(seqno));
// Using data() instead of begin() significantly improves performance. See #104.
iota(payload.data(), payload.data() + payload.size(), static_cast<char>(seqno));
if (!m_enable_metrics)
return;

Expand Down

0 comments on commit 633eb69

Please sign in to comment.