Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2006-10

inlining functions

4 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Marc Santhoff

Hi,

when using "inline" on a procedure or function, does it completely avoid the call by copying anything inside the "begin ... end" block to the right place?

Example:

function anythingFunc(v: integer):real; inline;
begin
	... some calculations ...
end;
function TMyObject.callAnything(v: integer):real;
begin
	result := anythingFunc(v);
end

This will result in two levels of calls (one for the method of TMyObject and one from inside the method to the global function) without inlining.

I assume with inline on it is only *one* call, which would be a speed improvement especially when called often.

Can someone confirm I understand this correctly?

TIA,
Marc

Reply by email

Michael Van Canneyt
to Marc Santhoff
Marc Santhoff wrote 5 lines
Hi, when using "inline" on a procedure or function, does it completely avoid the call by copying anything inside the "begin ... end" block to the right place?

Yes, that's the idea.

Michael.

Reply by email

Marc Santhoff
to Michael Van Canneyt
Michael Van Canneyt wrote 10 lines
On Thu, 19 Oct 2006, Marc Santhoff wrote: > Hi, > > when using "inline" on a procedure or function, does it completely avoid > the call by copying anything inside the "begin ... end" block to the > right place? Yes, that's the idea.

Beautiful, that saves me from losing syntax highlighting when using macros instead and is much more readable.

Thanks,
Marc

Reply by email

���� ����������� � mail.ru
to Marc Santhoff
Show quoted text 5 lines
> > Hi, > > when using "inline" on a procedure or function, does it completely avoid > > the call by copying anything inside the "begin ... end" block to the > > right place? > Yes, that's the idea.

"INLINE" is a suggestion, not obligation: sometimes they are compiled with "CALL". It looks especially not great when trying to inline assembler procedures.

Calling an inline function from another inline function may (or may not) obfuscate your debug information.

Reply by email