▲ | LegionMammal978 3 days ago | ||||||||||||||||||||||
You can get another 56% speedup on the reserve()+emplace_back() version just by replacing (Widget widget) with (const Widget& widget) in the function declaration [0], more of a difference than any of the loops. As well as a further 39% speedup by moving transformed_data into repsonse.data instead of copying it [1]. My takeaway is that C++ makes it extremely easy to copy data around unnecessarily. Also, you should always profile your code for easy wins before making drastic changes. | |||||||||||||||||||||||
▲ | jeffbee 3 days ago | parent [-] | ||||||||||||||||||||||
In this degenerate example, the completely straightforward way is tied for fastest as well. It's clear this has nothing to do with ranges.
| |||||||||||||||||||||||
|