I think it'd be neat if Intellij could recommend m...
# random
h
I think it'd be neat if Intellij could recommend making a function inline. I find it hard to know when to do so.
t
I would do it in special cases only, JIT is already inlining at runtime.
3
d
Most of the time you don't want to inline functions, because it messes with the JIT's optimization procedures. There are a few exceptions, mostly dealing with lambdas and crossinline lambdas, and my experience is that IDEA does give hints in those situations.
👍 1
h
orite... i'm ashamed to say i honestly can't conceive of such a special case
i think the only time i ever use inline is when it is impossible to write the function otherwise (iirc), or i'm modelling a function off a stdlib one
d
I would guess those are more or less the correct situations 🙂
👍 1
1
s
the rule of thumb I’ve used is either a)
reified
or b) takes a lambda
d
Unless you're in Kotlin/Native I guess.
l
Or on Android, where lambda allocation is costly, and where R8 can spot code duplication and make a method to reduce output size too.