[fpc-devel] Optimizing unused return values of inline functions
Michael Van Canneyt
michael at freepascal.org
Mon Aug 21 08:39:11 CEST 2017
On Sun, 20 Aug 2017, Benito van der Zander wrote:
> Hi,
>
> why does fpc not remove the calculation of the return value of inline
> functions, when the return value is unused?
>
> For example
>
> type TUtility = class
> function doSomething: TUtility; inline;
> end;
>
>
> It is a popular pattern to add result := self; to _every_ method (or result
> := @self in objects/records), so it can be chained as
> dosomething().dosomething().dosomething(),.....
> but one cannot use it with fpc efficiently, when it inserts too many
> unnecessary instructions
A strange statement.
This pattern is not inherently efficient. Why should it be ?
It's just something that boiled over from other languages and some people
see it as a nifty way of writing code.
Michael.
More information about the fpc-devel
mailing list