[JS IR BE] Implement *Array.plus(Collection<>) in typed Kotlin without dynamic helper
This commit is contained in:
@@ -1015,21 +1015,30 @@ public actual operator fun <T> Array<out T>.plus(elements: Collection<T>): Array
|
||||
* Returns an array containing all elements of the original array and then all elements of the given [elements] collection.
|
||||
*/
|
||||
public actual operator fun ByteArray.plus(elements: Collection<Byte>): ByteArray {
|
||||
return fillFromCollection(this.copyOf(size + elements.size), this.size, elements)
|
||||
var index = size
|
||||
val result = this.copyOf(size + elements.size)
|
||||
for (element in elements) result[index++] = element
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing all elements of the original array and then all elements of the given [elements] collection.
|
||||
*/
|
||||
public actual operator fun ShortArray.plus(elements: Collection<Short>): ShortArray {
|
||||
return fillFromCollection(this.copyOf(size + elements.size), this.size, elements)
|
||||
var index = size
|
||||
val result = this.copyOf(size + elements.size)
|
||||
for (element in elements) result[index++] = element
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing all elements of the original array and then all elements of the given [elements] collection.
|
||||
*/
|
||||
public actual operator fun IntArray.plus(elements: Collection<Int>): IntArray {
|
||||
return fillFromCollection(this.copyOf(size + elements.size), this.size, elements)
|
||||
var index = size
|
||||
val result = this.copyOf(size + elements.size)
|
||||
for (element in elements) result[index++] = element
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1043,14 +1052,20 @@ public actual operator fun LongArray.plus(elements: Collection<Long>): LongArray
|
||||
* Returns an array containing all elements of the original array and then all elements of the given [elements] collection.
|
||||
*/
|
||||
public actual operator fun FloatArray.plus(elements: Collection<Float>): FloatArray {
|
||||
return fillFromCollection(this.copyOf(size + elements.size), this.size, elements)
|
||||
var index = size
|
||||
val result = this.copyOf(size + elements.size)
|
||||
for (element in elements) result[index++] = element
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing all elements of the original array and then all elements of the given [elements] collection.
|
||||
*/
|
||||
public actual operator fun DoubleArray.plus(elements: Collection<Double>): DoubleArray {
|
||||
return fillFromCollection(this.copyOf(size + elements.size), this.size, elements)
|
||||
var index = size
|
||||
val result = this.copyOf(size + elements.size)
|
||||
for (element in elements) result[index++] = element
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1064,7 +1079,10 @@ public actual operator fun BooleanArray.plus(elements: Collection<Boolean>): Boo
|
||||
* Returns an array containing all elements of the original array and then all elements of the given [elements] collection.
|
||||
*/
|
||||
public actual operator fun CharArray.plus(elements: Collection<Char>): CharArray {
|
||||
return fillFromCollection(this.copyOf(size + elements.size), this.size, elements)
|
||||
var index = size
|
||||
val result = this.copyOf(size + elements.size)
|
||||
for (element in elements) result[index++] = element
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user