
6 Oct
2011
6 Oct
'11
7:56 p.m.
Stewart, Robert wrote:
The never ending reference to std::string vs const char* performance thing. In the "meow" example above, forcing the construction of a std::string from the string literal implies a free store allocation which, in turn, generally implies a global lock. That means it can be a drag on MT
Christian Holmquist wrote: performance. A library function shouldn't impose that if preventing or avoiding it is practicable.
Furthermore, constructing the temporary is O(N) in the length of the string, while the comparison will often only need to look at the first element. Regards, Phil.