[fpc-devel] Optimizing unused return values of inline functions

Benito van der Zander benito at benibela.de
Mon Aug 21 12:12:05 CEST 2017


Hi,

> This pattern is not inherently efficient. Why should it be ? 


It is not efficient, because of the pointless instruction!



Bye,
Benito



Am 21.08.2017 um 08:39 schrieb Michael Van Canneyt:
>
>
> 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.
> _______________________________________________
> fpc-devel maillist  -  fpc-devel at lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20170821/c3caa349/attachment.html>


More information about the fpc-devel mailing list