[Bug libstdc++/29037] performance problem with std::string operator=(const std::string& str);

neundorf at kde dot org gcc-bugzilla@gcc.gnu.org
Tue Sep 12 17:55:00 GMT 2006

------- Comment #5 from neundorf at kde dot org  2006-09-12 17:55 -------
std::string cacheKey;
for (...several files...)
  for(std::vector<std::string>::const_iterator i =
       this->IncludePath->begin(); i != this->IncludePath->end(); ++i)
  ... do something

Why would this be faster ?
The resize() happend only once at the beginning, before the iteration starts.
And even with the reserve(), the reserve() would happen everytime before the
inner loop (which iterates over the vector), and then the memory allocations
would happen ?
What's the exact difference between reserve() and resize() ?



More information about the Gcc-bugs mailing list