https://kotlinlang.org logo
j

jimn

08/02/2021, 1:32 AM
realistically which of these inlines cleaner?
val foo by delegate::foo
or
inline val foo get()=delegate.foo
I know which one shows up in the icicle graph like a bag of cinder blocks
y

Youssef Shoaib [MOD]

08/02/2021, 1:55 AM
most likely the second one since it becomes a direct call to
delegate.foo
j

jimn

08/02/2021, 1:58 AM
this is counter-intuitive to the postulate :: > ()
y

Youssef Shoaib [MOD]

08/02/2021, 4:15 AM
I'm not sure where you got the information that
::
is more performant than
()
. In fact, usually it isn't unless you're calling an inline function with
::
as a lambda argument. I think most Kotlin devs immediately recognise
::
as a sign that there isn't huge performance optimisations done to said code because (in some cases)
::
can result in a function reference which uses costly reflection.
j

jimn

08/02/2021, 4:23 AM
when we're discussing a delegate on a vtable, or when 30 years ago we would be, :: > (*a.b) and () fast forward to present day where an interface delegation is a shim and an inline is a faster shim you would still wonder about :: costing more than any declarative keyword magic.
until that's taken care of,
by ::
will necessarily involve more machinery
u

udalov

08/02/2021, 7:04 PM
In the upcoming Kotlin 1.6, we've optimized properties which delegate directly to other properties, so
val foo by delegate::foo
will almost literally mean
val foo get() = delegate.foo
. https://youtrack.jetbrains.com/issue/KT-39054
👍 2
j

jimn

08/04/2021, 1:28 AM
is there a gap list of kotlin IR vs. llvm ir features? last i knew this was the first and foremost assumption of llvm optimization unless you fancy -O0