Inline
When an inline subroutine or function is generated, the computational expense of a call and return is removed by inserting the subroutine or function statement block at the point where the original call was made. By default, the compiler will make all subroutines and functions inline, if they are called only once from your program. For example, the following Print() subroutine
sub Print()
USART.Write("Hello World", 13, 10)
end sub
SetBaudrate(br19200)
Print
USART.Write("The End", 13, 10)
would be converted to inline, which is the same as writing,
SetBaudrate(br19200)
USART.Write("Hello World", 13, 10)
USART.Write("The End", 13, 10)
You can force the compiler to always inline a subroutine or function by
prefixing the declaration with the inline keyword. For example,
inline sub Print()
USART.Write("Hello World", 13, 10)
end sub
To prevent the compiler from making a subroutine or function inline, simply prefix the declaration with the noinline keyword. For example,
noinline sub Print()
USART.Write("Hello World", 13, 10)
end sub
Take care when explicitly making a subroutine or function inline. Although inline routines remove the time overhead associated with making a call, there can be a significant cost in terms of code space used. Generally, you should only use inline for very small routines that need to execute quickly.