On Sun, 25 Jun 2023, Hairy Pixels via fpc-pascal wrote:
On Jun 24, 2023, at 10:27 PM, Michael Van Canneyt via fpc-pascal
<fpc-pascal@lists.freepascal.org> wrote:
It seems to me no gain is to be had from e.g. inlining a routine of 500+ lines
of code.
What if the function was only called from 3 places in the program and each
one of those was in something with very long loops, say 1 million
iterations? If you inline you'd get only an extra 1000 lines of code size
but save 3 million function calls which could be a big savings.
I doubt there will be any gain: 500 lines of code will result in many
thousands of assembler instructions being executed 3 million times.
The few additional instructions generated by a function call are dwarfed by
that.
More importantly: Inline is an automatism to optimize where possible.
You can always find exceptional cases which will not be handled by an
automatism. They are irrelevant. It's the bulk of cases that needs to be
solved by automatisms.
Michael.
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal