[cmake-developers] dependency scanning speed
Tanner Lovelace
clubjuggler at gmail.com
Mon Sep 11 09:50:52 EDT 2006
On 9/11/06, Bill Hoffman <bill.hoffman at kitware.com> wrote:
> At 05:46 PM 9/10/2006, Alexander Neundorf wrote:
> >3) it uses std::string::resize(4*1024) to preallocate space for the strings,
> >and then assigns always c_str() instead of the std::string itself, since
> >assigning the std::string apparently throws away the preallocated memory so
> >that the memory has to be allocated again if the string grows (which it does
> >often when creating the key for the header location cache). This saves
> >another 4 seconds.
>
> This one concerns me. Is this always legal to do?
My guess would be that it's implementation dependent. A function
can be used as an lvalue when the return type is a reference, but
c_str()'s return type is a character pointer. While many implementations
will certainly just return a pointer to the internal character representation
there's no guarantee that will happen or that the implementation won't
suddenly change at some point.
Cheers,
Tanner Lovelace
--
Tanner Lovelace
clubjuggler at gmail dot com
http://wtl.wayfarer.org/
(fieldless) In fess two roundels in pale, a billet fesswise and an
increscent, all sable.
More information about the cmake-developers
mailing list