When you embed a function, its calls will be replaced by the body itself at compile time. This can be used to squeeze the last bit of performance from a specific function call, eliminating the overhead of one function call. Unfortunately, this also makes it difficult to read the stack, since the original function does not really exist in the compiled code. Therefore, when you use inlining, you must be sure that the built-in function is bulletproof, otherwise your code will be much more difficult to debug.
I would really not bother with inlining unless you have a simple function called all the time. Take a look at the Elixir source code to get a view that uses inline — you will find the main functions that work with lists, maps, etc. and will probably be very common. Please note that even inside Elixir source code, inlining is used very sparingly, because you will only use it in some rare cases.
Patrick oscity
source share