JS: use slice() instead of slice(0) to copy arrays (minor).
This commit is contained in:
@@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package kotlin
|
||||
|
||||
import java.util.*
|
||||
@@ -68,7 +84,7 @@ internal fun arrayCopyResize(source: dynamic, newSize: Int, defaultValue: Any?):
|
||||
}
|
||||
|
||||
internal fun <T> arrayPlusCollection(array: dynamic, collection: Collection<T>): dynamic {
|
||||
val result = array.slice(0)
|
||||
val result = array.slice()
|
||||
result.length += collection.size
|
||||
var index: Int = array.length
|
||||
for (element in collection) result[index++] = element
|
||||
|
||||
@@ -79,7 +79,7 @@ public inline fun ShortArray.asList(): List<Short> {
|
||||
*/
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
public inline fun <T> Array<out T>.copyOf(): Array<T> {
|
||||
return this.asDynamic().slice(0)
|
||||
return this.asDynamic().slice()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -87,7 +87,7 @@ public inline fun <T> Array<out T>.copyOf(): Array<T> {
|
||||
*/
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
public inline fun BooleanArray.copyOf(): BooleanArray {
|
||||
return this.asDynamic().slice(0)
|
||||
return this.asDynamic().slice()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -95,7 +95,7 @@ public inline fun BooleanArray.copyOf(): BooleanArray {
|
||||
*/
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
public inline fun ByteArray.copyOf(): ByteArray {
|
||||
return this.asDynamic().slice(0)
|
||||
return this.asDynamic().slice()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -103,7 +103,7 @@ public inline fun ByteArray.copyOf(): ByteArray {
|
||||
*/
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
public inline fun CharArray.copyOf(): CharArray {
|
||||
return this.asDynamic().slice(0)
|
||||
return this.asDynamic().slice()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -111,7 +111,7 @@ public inline fun CharArray.copyOf(): CharArray {
|
||||
*/
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
public inline fun DoubleArray.copyOf(): DoubleArray {
|
||||
return this.asDynamic().slice(0)
|
||||
return this.asDynamic().slice()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -119,7 +119,7 @@ public inline fun DoubleArray.copyOf(): DoubleArray {
|
||||
*/
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
public inline fun FloatArray.copyOf(): FloatArray {
|
||||
return this.asDynamic().slice(0)
|
||||
return this.asDynamic().slice()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -127,7 +127,7 @@ public inline fun FloatArray.copyOf(): FloatArray {
|
||||
*/
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
public inline fun IntArray.copyOf(): IntArray {
|
||||
return this.asDynamic().slice(0)
|
||||
return this.asDynamic().slice()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -135,7 +135,7 @@ public inline fun IntArray.copyOf(): IntArray {
|
||||
*/
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
public inline fun LongArray.copyOf(): LongArray {
|
||||
return this.asDynamic().slice(0)
|
||||
return this.asDynamic().slice()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -143,7 +143,7 @@ public inline fun LongArray.copyOf(): LongArray {
|
||||
*/
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
public inline fun ShortArray.copyOf(): ShortArray {
|
||||
return this.asDynamic().slice(0)
|
||||
return this.asDynamic().slice()
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -58,7 +58,7 @@ fun specialJS(): List<GenericFunction> {
|
||||
returns("SELF")
|
||||
returns(ArraysOfObjects) { "Array<T>" }
|
||||
body {
|
||||
"return this.asDynamic().slice(0)"
|
||||
"return this.asDynamic().slice()"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user