On 24/02/2019 16:48, Jonas Maebe wrote:

You can disable these exception frames with {$implicitexceptions off}. If you want to disable it for TObject, you have to recompile the system unit with that switch, since the code for TObject's constructor is inside that unit.
ld never do this.

Actually use {$implicitexceptions off} on your inherited constructor, and do omit the call to "inherited Create" where it would call TObject.Create.
That assumes, that TObject is the only parent in the RTL (or fpc packages)

But it seems that the current way of protecting the constructor is more costly than needed.
Each constructor (and each parent constructor) has/have a try/except.

The parent constructor should only need this, if they are called directly, but not if they are called via inherited (equals called on the instance).

In fact if I do "ObjIntstance.Create()" an implicit try/except is created.
In the except handler is a test, that will skip calling the destructor in this case, meaning there will be no action in the except handler.

The constructor code already tests if it is called on an instance or not, to decide if it needs to call NewInstance. It could do the same (actually use the very same conditional block) to decide on creating the try/except.

This would reduce the amount of times, that an implicit handler is actually created.

_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply via email to