This is because there is an extra (implicit) Try/Finally block.
Thank you and Peter for answers. This way I was able to see how try...finally section looks in assembler :) Anyway, I understand that the answer is "can't be speed up". OK, I can live with that.
That is not correct. For your own code you can disable the implicit exception frame with a directive:
{$IMPLICITEXCEPTIONS OFF}
Indeed when I put {$IMPLICITEXCEPTIONS OFF} at the beginning of demo_resourcestring_slow.pas, Foo_Normal and Foo_ResourceString work equally fast. Nice, that's a solution in cases when I know that some code will not exit with exception.
But I risk that if I ever call Foo_ResourceString(-1) that will raise exception from Foo_ResourceString, I can get memory leaks, right ? Or can I predict in certain cases that using {$IMPLICITEXCEPTIONS OFF} is safe (no memory leaks) even when procedure will raise some exceptions ? If the answer is yes, then maybe it's safe to compile parts of FPC sources in lists.inc (like TList.Get) inside {$IMPLICITEXCEPTIONS OFF} ?
-- Michalis
_______________________________________________ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel