JS: Do not create a copy of already cloned vararg array.

JVM: Do not create copy of vararg array it it's already Object[].
This commit is contained in:
Ilya Gorbunov
2016-02-17 19:30:26 +03:00
parent c69d332db9
commit cbd38f007c
3 changed files with 51 additions and 21 deletions
+7 -3
View File
@@ -75,6 +75,10 @@ internal fun <T> arrayPlusCollection(array: dynamic, collection: Collection<T>):
return result
}
// copies vararg array due to different spread vararg behavior in JS.
// After fixing #KT-6491 may return `this`
internal inline fun <T> Array<out T>.varargToArrayOfAny(): Array<out Any?> = this.copyOf()
internal inline fun <T> Array<out T>.copyToArrayOfAny(isVarargs: Boolean): Array<out Any?> =
if (isVarargs)
// no need to copy vararg array in JS
this
else
this.copyOf()