Форум: "Потрепаться";
Текущий архив: 2004.12.12;
Скачать: [xml.tar.bz2];
Внизinline Найти похожие ветки
← →
TUser © (2004-11-25 13:25) [0]Просвятите меня - что такое inline-функции? Говорят они в D2005 повились.
← →
Игорь Шевченко © (2004-11-25 13:27) [1]"The Delphi compiler allows functions and procedures to be tagged with the inline directive to improve performance. If the function or procedure meets certain criteria, the compiler will insert code directly, rather than generating a call. Inlining is a performance optimization that can result in faster code, but at the expense of space. Inlining always causes the compiler to produce a larger binary file. The inline directive is used in function and procedure declarations and definitions, like other directives.
procedure MyProc(x:Integer); inline;
begin
// ...
end;
function MyFunc(y:Char) : String; inline;
begin
// ..
end;
The inline directive is a suggestion to the compiler. There is no guarantee the compiler will inline a particular routine, as there are a number of circumstances where inlining cannot be done. The following list shows the conditions under which inlining does or does not occur:
Inlining will not occur on any form of late-bound method. This includes virtual, dynamic, and message methods.
Routines containing assembly code will not be inlined.
Constructors and destructors will not be inlined.
The main program block, unit initialization, and unit finalization blocks cannot be inlined.
Routines that take open array parameters cannot be inlined.
Code can be inlined within packages, however, inlining never occurs across package boundaries.
No inlining will be done between units that are circularly dependent. This included indirect circular dependencies, for example, unit A uses unit B, and unit B uses unit C which in turn uses unit A. In this example, when compiling unit A, no code from unit B or unit C will be inlined in unit A.
The compiler can inline code when a unit is in a circular dependency, as long as the code to be inlined comes from a unit outside the circular relationship. In the above example, if unit A also used unit D, code from unit D could be inlined in A, since it is not involved in the circular dependency.
If a routine is defined in the interface section and it accesses symbols defined in the implementation section, that routine cannot be inlined.
Routines in classes cannot be inlined if they access members with less (i.e. more restricted) visibility than the method itself. For example, if a public method accesses private symbols, it cannot be inlined.
If a routine marked with inline uses external symbols from other units, all of those units must be listed in the uses statement, otherwise the routine cannot be inlined.
Procedures and functions used in conditional expressions in while-do and repeat-until statements cannot be expanded inline.
If you modify the implementation of an inlined routine, you will cause all units that use that function to be recompiled. This is different from traditional rebuild rules, where rebuilds were triggered only by changes in the interface section of a unit.
The {$INLINE} compiler directive gives you finer control over inlining. The {$INLINE} directive can be used at the site of the inlined routine"s definition, as well as at the call site. Below are the possible values and their meaning:
Value Meaning at definition Meaning at call site
{$INLINE ON} (default)
The routine is compiled as inlineable if it is tagged with the inline directive.
The routine will be expanded inline if possible.
{$INLINE AUTO} Behaves like {$INLINE ON}, with the addition that routines not marked with inline will be inlined if their code size is less than or equal to 32 bytes.
{$INLINE AUTO} has no effect at the call site.
{$INLINE OFF} The routine will not be marked as inlineable, even if it is tagged with inline.
The routine will not be expanded inline.
"
ПросвЯтись.
← →
TUser © (2004-11-25 13:28) [2]Спасибо
> ПросвЯтись.
Извините :)
Страницы: 1 вся ветка
Форум: "Потрепаться";
Текущий архив: 2004.12.12;
Скачать: [xml.tar.bz2];
Память: 0.45 MB
Время: 0.061 c