Instead of calling a routine, you move the code from the routine itself and expand it in place of the call. In addition to manual inlining, some languages support automatic inlining where the compiler or some other pre-compiler decides when to inline a code routine. Also, some languages allow for developer defined inlining where the developer can suggest and/or force the inlining of a code routine. Inlining can optimize your code for speed by saving a call and return, and parameter management.
Instead of calling a routine, you move the code from the routine itself and expand it in place of the call. In addition to manual inlining, some languages support automatic inlining where the compiler or some other pre-compiler decides when to inline a code routine. Also, some languages allow for developer defined inlining where the developer can suggest and/or force the inlining of a code routine. Inlining can optimize your code for speed by saving a call and return, and parameter management.
Inlining and .Net
In .Net, inlining is automatically done for you by the JIT compiler for all languages and in general leads to faster code for all programmers whether they are aware of inlining or not. Developer defined inlining of methods is not supported.
Inlining and C++
In both Visual C++ and C++Builder, use the inline (standard C++) or __inline (standard C and C++) keywords to suggest to the compiler to inline a routine.
Inlining and Delphi
Delphi introduced developer defined function and procedure inlining with Delphi 2005. Use the inline keyword to tell the compiler to inline a routine. Since Delphi will always try to inline the routine, make sure you test for speed because inlining a routine can lead to slower code under some circumstances.
Inlining and Java
The Java compiler automatically inlines when it determines a benefit. The use of final methods is considered a compiler hint to tell the compiler to inline the method if beneficial.
Inlined Foreign Code (Embedded Code)
The term inline is also used when one language is embedded (inlined) within another language. For example, when JavaScript code is embedded in HTML, or a C function into Perl, etc.