Avoid the overhead of a method call for small,
frequently called methods by marking them with the inline
directive.
TSomeClass =
class
public
procedure DoSomething; inline;
end;
Notes
The
inline keyword should be used sparingly after you have identified
performance bottlenecks using a profiler and when there is a
measurable performance improvement from doing so. Anything else is
premature optimisation which as we all know rarely works the way
you expect it to.
The
compiler reserves the right to ignore your use of inline if it
thinks you're being stupid.
The
{$INLINE <ON|OFF|AUTO>} compiler directive (which defaults to
ON) can be set to OFF to disable all inlining or AUTO to tell the
compiler to automatically inline any small routines it thinks are
good candidates. The AUTO setting should be used with care as it
may result in a bloat of executable size.