[Insight-developers] Empty FixedArray destructor: Performancehit using gcc (times 2)
Niels Dekker
niels-xtk at xs4all.nl
Thu Jun 5 15:02:02 EDT 2008
Bill Lorensen wrote:
> Here is an FAQ on destructors:
> http://www.informit.com/guides/content.aspx?g=cplusplus&seqNum=370
> They say that an empty destructor is pretty much useless.
The destructor of FixedArray<TValueType, VLength> invokes the destructor
of TValueType for all of its elements. So it may not be as empty as it
seems... When the destructor is removed from FixedArray, it will be
implicitly defined as an inline function, as the FAQ you're referring to
says. This might give a performance gain, but it might also produce a
larger binary. Things might get worse (or better?) when TValueType
itself has also has an inline destructor.
In some special cases, the destructor of a class /must/ be implemented
in a CXX file, even if it is empty. As is the case discussed at
GameDev.Net, "auto_ptr within Pimpl Class",
http://www.gamedev.net/community/forums/topic.asp?topic_id=437587
Anyway, just my 2 cents. It might still be okay to remove FixedArray's
destructor...
Kind regards,
--
Niels Dekker
http://www.xs4all.nl/~nd/dekkerware
Scientific programmer at LKEB, Leiden University Medical Center
More information about the Insight-developers
mailing list