jimn
12/07/2019, 4:58 PMBurkhard
12/07/2019, 6:05 PMBurkhard
12/07/2019, 6:07 PMfoo(**list.toArray())*
is even worse on performance since the data will get copied twice. toArray()
creates one copy and the spread operator will create another one. I think there is a youtrack issue about it but I can’t find it right now.jimn
12/07/2019, 6:42 PMjimn
12/07/2019, 7:00 PM@JvmName("getVA")
inline operator fun <reified T> Array<T>.get(vararg index: Int) = get(index)
inline operator fun <reified T> Array<T>.get( index: IntArray) = Array(index.size) { i: Int -> this[index[i]] }
this refactoring just reduced my heap allocations by 50%jimn
12/07/2019, 7:01 PMjimn
12/07/2019, 7:55 PM@JvmName("getVA")
inline operator fun <reified T> Array<T>.get(vararg index: Int) = get(index)
inline operator fun <reified T> Array<T>.get( index:
IntArray) = Array(index.size) { i: Int -> this[index[i]] }
foo[3,2,1]
is extremely handy to have for an array copy operator, likewise list im sure.