So, tell me if I'm wrong. AFAIK, *`inline` sacrifi...
# getting-started
b
So, tell me if I'm wrong. AFAIK,
inline
sacrifices the size of the binary in favor of fewer stack frames and faster execution.
Is that correct? Is it more subtle or complex? Is there anything else it does that I should know?
v
Not quite
Nobody cares about the number of stack frames because JIT optimizes it on its own
More other, inlining things may break some JIT optimizations and slow down the execution
inline
in Kotlin allows: 1) to skip creating objects when using lambdas 2) to reduce method count for trivial methods 3) to get richer control flow
b
I see... How can I tell if I shouldn't be `inline`ing something?
v
The simple answer it to never
inline
unless you know what you are doing
A more complete advice is to respect IJ when it tells you that something shouldn't be inlined
Actually I am surprised it is NOT in the docs https://kotlinlang.org/docs/reference/inline-functions.html