[fpc-devel] Looking for clarification on what I think are obviously missing "const" prefixes for parameters in the methods of TRect (the typshrdh.inc one)

Mattias Gaertner nc-gaertnma at netcologne.de
Sun Jan 27 14:23:25 CET 2019


On Sun, 27 Jan 2019 13:11:53 +0000
Walter Prins <wprins at gmail.com> wrote:

>[...]
> Just thinking out loud (probably a bad idea) but:
> 
> Would it perhaps be possible to treat this as a type of optimization
> however?  Which is to say, if the called routine makes no changes to
> the passed record, then it should not matter whether compiler
> implicitly const passes the parameter or copies it?  (If the routine
> *does* change the passed record then it does the normal thing.)  Of
> course I have no idea whether the dataflow analysis I imagine needed
> to support this is whatsoever plausible to be done without
> unacceptable compromises  (And even then, I'd guess it's not
> something there'd be sufficient appetite for even if in theory it
> might be possible...?)

It is possible. 
Note that changing the signature needs a wrapper when creating a proc
value:
Proc:=@TheOptimizedProc;

Mattias



More information about the fpc-devel mailing list