DEV Community

Discussion on: Efficient way of using std::vector

Collapse
 
zhu48 profile image
Zuodian Hu

Another fun way STL containers can be misused is not understanding the underlying memory management enough. Growing an std::vector by naively pushing elements and letting the container grow automatically is much, much slower than pre-allocating if you know the roughly how large your data set will be.

Collapse
 
reg__ profile image
Adam Sawicki

That's right, I fully agree.