https://kotlinlang.org logo
#getting-started
Title
# getting-started
b

benleggiero

03/10/2017, 1:41 AM
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

voddan

03/10/2017, 6:33 AM
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

benleggiero

03/16/2017, 2:38 PM
I see... How can I tell if I shouldn't be `inline`ing something?
v

voddan

03/16/2017, 2:50 PM
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