[fpc-pascal] Program efficiency
pascaldragon at googlemail.com
Wed Nov 9 14:08:03 CET 2022
James Richters via fpc-pascal <fpc-pascal at lists.freepascal.org> schrieb am
Mi., 9. Nov. 2022, 13:47:
> In other words.. is
> O:= A+G-K;
> Less efficient than
> O:= ((B+C/D)-E^F)+ (H*(I+J))-(L+M/N);
> Or does it end up being the same when it's done?
The compiler will insert temporary variables anyway when necessary (so even
your first example might infact contain more variables and your second will
very likely contain temporaries).
Using optimizations (especially regvars, used by default in -O2) might
improve this independent of whether you use variables yourself or not.
But in general: you should look at other things to optimize and only come
back to this when you have nothing easier to improve.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the fpc-pascal