I'm currently making an application using vectors with C++.
I know how pre-optimization is the root of all evil.
But I really can't help being curious.
I'm adding parts of other vectors into another vector.
We'll say the vector will have a size that never changes of 300.
Since I always append to the end of the vector
Is it faster to do:
a.reserve(300);
a.insert(a.end(), b.begin(), b.end());
or would it be faster to loop through the vector I want to append and add each items individually(while still reserving beforehand) with push_back
or emplace
. (unsure which is faster)
Anyone can help me on this?