Use std::vector<T>::reserve() to reserve memory