[cmake-developers] dependency scanning speed
Tanner Lovelace
clubjuggler at gmail.com
Mon Sep 11 13:24:06 EDT 2006
On 9/11/06, Alexander Neundorf <neundorf at kde.org> wrote:
> Can you please compile and run the attached file with gcc 4.0 and if possible
> gcc 4.1 and post the output here ?
> Maybe the capacity-behaviour is already "fixed" in current gcc.
Actually, I believe it's expected behavior. Assigning a string to another
string doesn't just copy the character contents to it, but also
copies all of the internals too. So, your second string, s2, is
created with only a capacity of 11, which is the length of the
string it's created with. Assigning it to s1 not only copies the
characters, but also copies the internals, including the capacity.
If you resize s2 before assigning it to s1, you'll notice that s1 ends
up with the newly resized capacity of s2.
So, if you want to avoid that behavior, setting a std::string using
c_str() is probably a good idea.
Cheers,
Tanner
--
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