3 ms·
But if you expect an upper bound of the required size of that stay, it may be worthwhile to explicitly set the capacity of the vector to avoid these reallocatio
by rerx 6y ago
But if you expect an upper bound of the required size of that stay, it may be worthwhile to explicitly set the capacity of the vector to avoid these reallocations.
- spacechild1 6y agoThat's exactly the purpose of std::vector's “reserve“ method, btw.
- twoodfin 6y agoI once worked with a C++ text processing library that saw more than a 50% throughput bump just from reserve()’ing std::string and std::vector space in hot code paths.