-
Delphi inline function
Posted on 25 June 2009 Neill No commentsStarting with the 2005 version of Delphi, it is possible to create inline functions, they significantly increase the speed of the code, due to the fact that do not generate a call of this function, but simply copy code to executing place. In so doing, excludes the steps associated with the allocation of function memory and the local variables, return values, etc. Instead of lines 10-15 is 3-5 lines of code for small functions for each execution point.
One important thing is that the use of inline function increases the size of the executable file, because the code function is duplicated in every place of the function call. So use it reasonable and desirable for small functions.
For example, search for a minimum of two numbers, which is called in a loop. To increase the productivity performance of the program of this small function, make it inline.
function min ( a, b: Interger ): Integer; inline;
begin
if (a < b) then Result := a
else Result := b;
end;
Programming DelphiLeave a Reply
You must be logged in to post a comment.

English
Russian
Recent Comments