Marc Knaup
12/11/2018, 8:46 AMinline fun test(vararg properties: Pair<String, Any?>) {
//(uses pairs)
}
test(
"a" to 1,
"b" to 2,
…
)
Can the compiler optimize away the Pair
allocations and maybe even the boxing?
if so, is inline
needed for that to happen?spand
12/11/2018, 8:48 AMgildor
12/11/2018, 8:53 AMMarc Knaup
12/11/2018, 8:57 AMInt.toString()
would suddenly be used instead of Integer.toString()
which may come unexpected 🤔gildor
12/11/2018, 8:58 AMThe binary incompatibility problem you always have with inline functionsIt’s not true. Because if you call such function from Java you actually call common, non-inline function (which also exist in your bytecode)
Marc Knaup
12/11/2018, 9:00 AMgildor
12/11/2018, 9:03 AMMarc Knaup
12/11/2018, 9:06 AMgildor
12/11/2018, 9:06 AMvalue types are being worked onAs I know nothing will happen until Java will not stabilise implementation details, so Kotlin can develop own value types based on this to be compatible with future version of JVM with value types
Array<Any>
and use odd elements as keys and even as values (with casting) in your function, not type safe, but will have the same performance as your inline-pairs optimizationMarc Knaup
12/11/2018, 9:11 AMmapOf
for example does get rid of the `Pair`s. But I could be wrong.gildor
12/11/2018, 9:11 AMit’s not true, there is no optimization as I knowfor example does get rid of the `Pair`smapOf