Ayfri
02/08/2022, 3:50 PMRuckus
02/08/2022, 3:59 PMFunction
objects for them (and often can avoid boxing of primitive generics). That can have a notable performance/overhead impact.
Without a lambda to inline, there isn't much you can expect in terms of gains, so there isn't much reason to do it.Ruckus
02/08/2022, 4:00 PMRuckus
02/08/2022, 4:01 PMRuckus
02/08/2022, 4:03 PMCasey Brooks
02/08/2022, 4:19 PMephemient
02/08/2022, 4:24 PMinline fun <T, K, V> Iterable<T>.associateBy(
keySelector: (T) -> K,
valueTransform: (T) -> V
): Map<K, V>
where multiple lambdas, including in non-tail position, are inlinedephemient
02/08/2022, 4:27 PMinline
, and larger functions probably shouldn't be inlined for code size/cache friendliness reasonsAyfri
02/08/2022, 4:28 PMephemient
02/08/2022, 4:30 PMRob Elliot
02/08/2022, 4:31 PMinline fun
when aliasing a function using an extension function with a different name - for instance like this:
interface Foo {
fun badName(): String
}
inline fun Foo.goodName() = badName()
I shouldn't imagine it saves much if anything, but it "feels" right - acknowledging that this is a compiler trick, and should disappear in the bytecode just like typealias GoodName = BadName
does. Good idea / bad idea / neither?ephemient
02/08/2022, 4:33 PMinterface Foo {
@Deprecated("do not use", replaceWith = ReplaceWith("goodName()"))
fun badName(): String
fun goodName(): String = badName()
}
to transition users to the new name as a member functionRob Elliot
02/08/2022, 4:34 PMFoo
ephemient
02/08/2022, 4:37 PMCasey Brooks
02/08/2022, 4:38 PMephemient
02/08/2022, 4:42 PM