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

Oleg Siboglov

04/19/2022, 5:41 PM
Hey all. I was hoping I could get some clarification about the
inline
modifier for functions. The Kotlin lang webpage for inline function states “Inlining may cause the generated code to grow. However, if you do it in a reasonable way (avoiding inlining large functions), it will pay off in performance, especially at “megamorphic” call-sites inside loops.” When it states that we should avoid inlining large functions, does this refer solely to the function receiving the
inline
modifier or does it apply to the contents of the lambda (which is being passed to the inlined function) as well?
j

Joffrey

04/19/2022, 8:16 PM
In my understanding, it doesn't include the lambda body. The problem of code growth is due to the repetition of the inlined code, but each lambda body is theoretically unique, so in that sense it doesn't contribute to the duplicated bytecode
o

Oleg Siboglov

04/19/2022, 9:07 PM
🙏
8 Views