The Little Things: The Missing Performance in std::vector

https://codingnest.com/the-little-things-the-missing-performance-in-std-vector/

10 points · 1 comments · view on lemmy.world

1 Comments

AlmightySnoo@lemmy.world · 4 pts · 2y

The lost performance comes from the fact that vector::push_back has to check whether it needs to grow the vector, even though it will never happen in the convert_to_indices function. A sufficiently smart compiler could optimize this out, but neither GCC nor Clang do (and MSVC makes a complete hash of things).

Ok that one is new to me, I didn't know that despite the .reserve the compilers are still unable to figure that out.