ref _ https://www.baeldung.com/kotlin/inline-functions
lambda function에서 예로
When using lambdas, the extra memory allocations and extra virtual method call introduce some runtime overhead.
inline 키워드를 사용하지 않으면 많은 부분에서 overhead가 발생 할 수있다.
inline 키워드는 same code를 direct로 executing 할 수 있게 도와주는 키워드이며 효율적이다
아 또한 과도한 사용은 좋지 않으며 generated code가 커지게되면 좋지 않다.
However, we should not overuse the inline functions, especially for long functions since the inlining may cause the generated code to grow quite a bit.
기본적으로 인라인 함수에서 전달된 모든 람다는 인라인 되기 때문에 uninlined를 이용하여 예외 시킬 수 있다.
inline fun foo(inlined: () -> Unit, noinline notInlined: () -> Unit) { ... }
All we have to do is to mark the type parameter with the reified keyword:
inline fun <reified T> Any.isA(): Boolean = this is T
Without inline and reified, the isA function wouldn’t compile, as we thoroughly explain in our Kotlin Generics article.
안좋은 소스코드, overhead가 많이 일어나는 코드를 판별한 방법은 코드를 generated 했을 때 bytecode size가 무수히 높았던 코드들이다.