raulraja
03/08/2019, 12:45 AMfoo { bar(it) }
has a performance cost over foo(bar)
allocating an extra lambda? If so is this something the Kotlin compiler already optimizes for?udalov
foo { bar(it) }
will create an extra lambdaraulraja
03/10/2019, 11:38 AMdmitry.petrov
03/11/2019, 2:50 PMfoo(::bar)
, if that's what you actually had in mind, will create an extra callable reference.
At the same time, if { bar(it) }
has trivial (empty) closure, compiler will generate a single static instance for lambda, and will reuse it.
So, it's a bit more complex.