Constructor Optimization
Benjamin Meyer
kde-optimize@mail.kde.org
Tue, 21 Jan 2003 14:41:47 -0500
Well a little bit more playing around and I have confirmed that gcc will =
not=20
optimize:
obj a =3D b + c + d...=20
to
obj a(b);
a +=3D c;
a +=3D d;
=2E...
The first one being the slower operation due to a New and copy at every s=
tep.
Combining "PRE_" rand() and "_POST": (used rand() simply to make sure th=
at=20
the compiler wouldn't optimize away everything and give real world result=
s)
+Operator test (1 line of code).
Normal Constructor, 1804289383
Normal Constructor, PRE_1804289383
operator+Copy, PRE_1804289383
Copy Constructor, PRE_1804289383
Normal Constructor, PRE_1804289383_POST
operator+Copy, PRE_1804289383_POST
Copy Constructor, PRE_1804289383_POST
Optimal +Operator. (multiple lines using overloaded +=3D)
Copy Constructor, PRE_
Normal Constructor, 846930886
operator+=3DCopy, PRE_846930886
operator+=3DCopy, PRE_846930886_POST
-Benjamin Meyer