On Wed, 1 Feb 2023, Hairy Pixels via fpc-devel wrote:



On Feb 1, 2023, at 8:16 PM, Adriaan van Os via fpc-devel 
<fpc-devel@lists.freepascal.org> wrote:

Because, if e.g. the byte-size of a parameter is such that it fits into a CPU 
register, then passing the parameter itself is more efficient than passing a 
reference to it. For large byte-size parameters, const and constref function 
the same. The difference is with small byte-size parameters.

Hmmm I was told otherwise by one of the compiler devs and that I should use 
constref if I want to guarantee it will not be copied. Maybe one of them can 
confirm this….

That's exactly what Adriaan is saying. With const the compiler can choose.
With constref, you force it not to copy. But this is not so efficient for
small parameter sizes.

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

Reply via email to