I want to re-use a vector<short> over and over in a performance critical loop. I only need the vector size to be reset to zero at the end of the loop. I'm worried that the myVector.clear() takes time to actually clear all the memory. Also, does the myVector.reserve() survive the clear()?
vector<short> myVector;
myVector.reserve(10000);
while(true)
{
for(int i = 0; i < 10000; ++i)
{
myVector.push_back(*something++);
}
writeOut(myVector);
myVector.clear();
}