a text on optimizing C++
David Faure
kde-optimize@mail.kde.org
Fri, 24 Jan 2003 14:24:23 +0100
=2D----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Friday 24 January 2003 14:18, David Leimbach wrote:
> > It looks almost the same, but the latter may also sometimes produce
> > shorter code. Upon entering the constructor body, all constructors of
> > attributes have already been executed. So in this example, in the latter
> > case attr2 is directly initialized using a copy constructor, while in t=
he
> > sooner case it's initialized using the default constructor, and then
> > operator=3D is used.
>=20
> So your claim is that with the initializer list the following has a short=
er=20
> execution path?
>=20
> SomeClass obj =3D someOtherObj;
>=20
> I don't think operator =3D is involved at all in the above line of code=20
> regardless of whether the constructor uses initializer lists or not. The=
=20
> above is *not* an assignment so why would it use the assignment operator?=
=20
> The above is an initialization that just happens to use the '=3D' token.
Yes it's an initialization. But the constructor has already initialized
the member object. This isn't about SomeClass obj =3D ...
but about
m_obj =3D ...
vs
Class::Class() : m_obj( ... ) {}
=2D --=20
David Faure -- faure@kde.org, dfaure@klaralvdalens-datakonsult.se
Klar=E4lvdalens Datakonsult AB, Platform-independent software solutions
Contributing to: http://www.konqueror.org/, http://www.koffice.org/
KOffice-1.2.1 is available - http://download.kde.org/stable/koffice-1.2.1/
=2D----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)
iD8DBQE+MT6I72KcVAmwbhARAnxuAJ9zYBX7yM087YuNvdJ0h9N1zKI0/wCdEF7M
RJBXRa4hvqaQFlzBoOV63JM=3D
=3DU7u2
=2D----END PGP SIGNATURE-----