realistically which of these inlines cleaner? `va...
# compiler
j
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
most likely the second one since it becomes a direct call to
delegate.foo
j
this is counter-intuitive to the postulate :: > ()
y
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
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
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
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