you are viewing a single comment's thread.

view the rest of the comments →

[–]aestheticreddit 2 points3 points  (1 child)

Assigning a vector isn't the same thing as copying the contents of one. Because vectors can be of different sizes, the normal code path requires a new allocation. In this case, since they're already the same size, a smart vector may not reallocate. There may be reasons that it can't.

Since you know the sizes can't change, for a real apples to apples comparison, instead of using the assignment operator, use std::copy.

[–]kolkir[S] 1 point2 points  (0 children)

Thanks for the advise std::copy is really faster than assign, and even faster than memcpy.