diff --git a/js/js.libraries/src/core/generated/_ArraysJs.kt b/js/js.libraries/src/core/generated/_ArraysJs.kt index 4b422050ddc..c2eb9a7571e 100644 --- a/js/js.libraries/src/core/generated/_ArraysJs.kt +++ b/js/js.libraries/src/core/generated/_ArraysJs.kt @@ -11601,7 +11601,7 @@ public infix fun CharArray.zip(other: Array): List> { * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. */ public inline fun Array.zip(other: Array, transform: (T, R) -> V): List { - val size = Math.min(size, other.size) + val size = minOf(size, other.size) val list = ArrayList(size) for (i in 0..size-1) { list.add(transform(this[i], other[i])) @@ -11613,7 +11613,7 @@ public inline fun Array.zip(other: Array, transform: (T, * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. */ public inline fun ByteArray.zip(other: Array, transform: (Byte, R) -> V): List { - val size = Math.min(size, other.size) + val size = minOf(size, other.size) val list = ArrayList(size) for (i in 0..size-1) { list.add(transform(this[i], other[i])) @@ -11625,7 +11625,7 @@ public inline fun ByteArray.zip(other: Array, transform: (Byte, R) * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. */ public inline fun ShortArray.zip(other: Array, transform: (Short, R) -> V): List { - val size = Math.min(size, other.size) + val size = minOf(size, other.size) val list = ArrayList(size) for (i in 0..size-1) { list.add(transform(this[i], other[i])) @@ -11637,7 +11637,7 @@ public inline fun ShortArray.zip(other: Array, transform: (Short, * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. */ public inline fun IntArray.zip(other: Array, transform: (Int, R) -> V): List { - val size = Math.min(size, other.size) + val size = minOf(size, other.size) val list = ArrayList(size) for (i in 0..size-1) { list.add(transform(this[i], other[i])) @@ -11649,7 +11649,7 @@ public inline fun IntArray.zip(other: Array, transform: (Int, R) - * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. */ public inline fun LongArray.zip(other: Array, transform: (Long, R) -> V): List { - val size = Math.min(size, other.size) + val size = minOf(size, other.size) val list = ArrayList(size) for (i in 0..size-1) { list.add(transform(this[i], other[i])) @@ -11661,7 +11661,7 @@ public inline fun LongArray.zip(other: Array, transform: (Long, R) * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. */ public inline fun FloatArray.zip(other: Array, transform: (Float, R) -> V): List { - val size = Math.min(size, other.size) + val size = minOf(size, other.size) val list = ArrayList(size) for (i in 0..size-1) { list.add(transform(this[i], other[i])) @@ -11673,7 +11673,7 @@ public inline fun FloatArray.zip(other: Array, transform: (Float, * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. */ public inline fun DoubleArray.zip(other: Array, transform: (Double, R) -> V): List { - val size = Math.min(size, other.size) + val size = minOf(size, other.size) val list = ArrayList(size) for (i in 0..size-1) { list.add(transform(this[i], other[i])) @@ -11685,7 +11685,7 @@ public inline fun DoubleArray.zip(other: Array, transform: (Double * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. */ public inline fun BooleanArray.zip(other: Array, transform: (Boolean, R) -> V): List { - val size = Math.min(size, other.size) + val size = minOf(size, other.size) val list = ArrayList(size) for (i in 0..size-1) { list.add(transform(this[i], other[i])) @@ -11697,7 +11697,7 @@ public inline fun BooleanArray.zip(other: Array, transform: (Boole * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. */ public inline fun CharArray.zip(other: Array, transform: (Char, R) -> V): List { - val size = Math.min(size, other.size) + val size = minOf(size, other.size) val list = ArrayList(size) for (i in 0..size-1) { list.add(transform(this[i], other[i])) @@ -11773,7 +11773,7 @@ public infix fun CharArray.zip(other: Iterable): List> { */ public inline fun Array.zip(other: Iterable, transform: (T, R) -> V): List { val arraySize = size - val list = ArrayList(Math.min(other.collectionSizeOrDefault(10), arraySize)) + val list = ArrayList(minOf(other.collectionSizeOrDefault(10), arraySize)) var i = 0 for (element in other) { if (i >= arraySize) break @@ -11787,7 +11787,7 @@ public inline fun Array.zip(other: Iterable, transform: (T, */ public inline fun ByteArray.zip(other: Iterable, transform: (Byte, R) -> V): List { val arraySize = size - val list = ArrayList(Math.min(other.collectionSizeOrDefault(10), arraySize)) + val list = ArrayList(minOf(other.collectionSizeOrDefault(10), arraySize)) var i = 0 for (element in other) { if (i >= arraySize) break @@ -11801,7 +11801,7 @@ public inline fun ByteArray.zip(other: Iterable, transform: (Byte, R) */ public inline fun ShortArray.zip(other: Iterable, transform: (Short, R) -> V): List { val arraySize = size - val list = ArrayList(Math.min(other.collectionSizeOrDefault(10), arraySize)) + val list = ArrayList(minOf(other.collectionSizeOrDefault(10), arraySize)) var i = 0 for (element in other) { if (i >= arraySize) break @@ -11815,7 +11815,7 @@ public inline fun ShortArray.zip(other: Iterable, transform: (Short, R */ public inline fun IntArray.zip(other: Iterable, transform: (Int, R) -> V): List { val arraySize = size - val list = ArrayList(Math.min(other.collectionSizeOrDefault(10), arraySize)) + val list = ArrayList(minOf(other.collectionSizeOrDefault(10), arraySize)) var i = 0 for (element in other) { if (i >= arraySize) break @@ -11829,7 +11829,7 @@ public inline fun IntArray.zip(other: Iterable, transform: (Int, R) -> */ public inline fun LongArray.zip(other: Iterable, transform: (Long, R) -> V): List { val arraySize = size - val list = ArrayList(Math.min(other.collectionSizeOrDefault(10), arraySize)) + val list = ArrayList(minOf(other.collectionSizeOrDefault(10), arraySize)) var i = 0 for (element in other) { if (i >= arraySize) break @@ -11843,7 +11843,7 @@ public inline fun LongArray.zip(other: Iterable, transform: (Long, R) */ public inline fun FloatArray.zip(other: Iterable, transform: (Float, R) -> V): List { val arraySize = size - val list = ArrayList(Math.min(other.collectionSizeOrDefault(10), arraySize)) + val list = ArrayList(minOf(other.collectionSizeOrDefault(10), arraySize)) var i = 0 for (element in other) { if (i >= arraySize) break @@ -11857,7 +11857,7 @@ public inline fun FloatArray.zip(other: Iterable, transform: (Float, R */ public inline fun DoubleArray.zip(other: Iterable, transform: (Double, R) -> V): List { val arraySize = size - val list = ArrayList(Math.min(other.collectionSizeOrDefault(10), arraySize)) + val list = ArrayList(minOf(other.collectionSizeOrDefault(10), arraySize)) var i = 0 for (element in other) { if (i >= arraySize) break @@ -11871,7 +11871,7 @@ public inline fun DoubleArray.zip(other: Iterable, transform: (Double, */ public inline fun BooleanArray.zip(other: Iterable, transform: (Boolean, R) -> V): List { val arraySize = size - val list = ArrayList(Math.min(other.collectionSizeOrDefault(10), arraySize)) + val list = ArrayList(minOf(other.collectionSizeOrDefault(10), arraySize)) var i = 0 for (element in other) { if (i >= arraySize) break @@ -11885,7 +11885,7 @@ public inline fun BooleanArray.zip(other: Iterable, transform: (Boolea */ public inline fun CharArray.zip(other: Iterable, transform: (Char, R) -> V): List { val arraySize = size - val list = ArrayList(Math.min(other.collectionSizeOrDefault(10), arraySize)) + val list = ArrayList(minOf(other.collectionSizeOrDefault(10), arraySize)) var i = 0 for (element in other) { if (i >= arraySize) break @@ -11954,7 +11954,7 @@ public infix fun CharArray.zip(other: CharArray): List> { * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. */ public inline fun ByteArray.zip(other: ByteArray, transform: (Byte, Byte) -> V): List { - val size = Math.min(size, other.size) + val size = minOf(size, other.size) val list = ArrayList(size) for (i in 0..size-1) { list.add(transform(this[i], other[i])) @@ -11966,7 +11966,7 @@ public inline fun ByteArray.zip(other: ByteArray, transform: (Byte, Byte) -> * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. */ public inline fun ShortArray.zip(other: ShortArray, transform: (Short, Short) -> V): List { - val size = Math.min(size, other.size) + val size = minOf(size, other.size) val list = ArrayList(size) for (i in 0..size-1) { list.add(transform(this[i], other[i])) @@ -11978,7 +11978,7 @@ public inline fun ShortArray.zip(other: ShortArray, transform: (Short, Short * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. */ public inline fun IntArray.zip(other: IntArray, transform: (Int, Int) -> V): List { - val size = Math.min(size, other.size) + val size = minOf(size, other.size) val list = ArrayList(size) for (i in 0..size-1) { list.add(transform(this[i], other[i])) @@ -11990,7 +11990,7 @@ public inline fun IntArray.zip(other: IntArray, transform: (Int, Int) -> V): * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. */ public inline fun LongArray.zip(other: LongArray, transform: (Long, Long) -> V): List { - val size = Math.min(size, other.size) + val size = minOf(size, other.size) val list = ArrayList(size) for (i in 0..size-1) { list.add(transform(this[i], other[i])) @@ -12002,7 +12002,7 @@ public inline fun LongArray.zip(other: LongArray, transform: (Long, Long) -> * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. */ public inline fun FloatArray.zip(other: FloatArray, transform: (Float, Float) -> V): List { - val size = Math.min(size, other.size) + val size = minOf(size, other.size) val list = ArrayList(size) for (i in 0..size-1) { list.add(transform(this[i], other[i])) @@ -12014,7 +12014,7 @@ public inline fun FloatArray.zip(other: FloatArray, transform: (Float, Float * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. */ public inline fun DoubleArray.zip(other: DoubleArray, transform: (Double, Double) -> V): List { - val size = Math.min(size, other.size) + val size = minOf(size, other.size) val list = ArrayList(size) for (i in 0..size-1) { list.add(transform(this[i], other[i])) @@ -12026,7 +12026,7 @@ public inline fun DoubleArray.zip(other: DoubleArray, transform: (Double, Do * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. */ public inline fun BooleanArray.zip(other: BooleanArray, transform: (Boolean, Boolean) -> V): List { - val size = Math.min(size, other.size) + val size = minOf(size, other.size) val list = ArrayList(size) for (i in 0..size-1) { list.add(transform(this[i], other[i])) @@ -12038,7 +12038,7 @@ public inline fun BooleanArray.zip(other: BooleanArray, transform: (Boolean, * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. */ public inline fun CharArray.zip(other: CharArray, transform: (Char, Char) -> V): List { - val size = Math.min(size, other.size) + val size = minOf(size, other.size) val list = ArrayList(size) for (i in 0..size-1) { list.add(transform(this[i], other[i])) diff --git a/js/js.libraries/src/core/generated/_CollectionsJs.kt b/js/js.libraries/src/core/generated/_CollectionsJs.kt index e3aebdd3dcd..5daff1d2c3c 100644 --- a/js/js.libraries/src/core/generated/_CollectionsJs.kt +++ b/js/js.libraries/src/core/generated/_CollectionsJs.kt @@ -1871,7 +1871,7 @@ public infix fun Iterable.zip(other: Array): List> { */ public inline fun Iterable.zip(other: Array, transform: (T, R) -> V): List { val arraySize = other.size - val list = ArrayList(Math.min(collectionSizeOrDefault(10), arraySize)) + val list = ArrayList(minOf(collectionSizeOrDefault(10), arraySize)) var i = 0 for (element in this) { if (i >= arraySize) break @@ -1893,7 +1893,7 @@ public infix fun Iterable.zip(other: Iterable): List> { public inline fun Iterable.zip(other: Iterable, transform: (T, R) -> V): List { val first = iterator() val second = other.iterator() - val list = ArrayList(Math.min(collectionSizeOrDefault(10), other.collectionSizeOrDefault(10))) + val list = ArrayList(minOf(collectionSizeOrDefault(10), other.collectionSizeOrDefault(10))) while (first.hasNext() && second.hasNext()) { list.add(transform(first.next(), second.next())) } diff --git a/js/js.libraries/src/core/generated/_StringsJs.kt b/js/js.libraries/src/core/generated/_StringsJs.kt index ad95686cc29..88497fa5d70 100644 --- a/js/js.libraries/src/core/generated/_StringsJs.kt +++ b/js/js.libraries/src/core/generated/_StringsJs.kt @@ -1135,7 +1135,7 @@ public infix fun CharSequence.zip(other: CharSequence): List> { * Returns a list of values built from characters of both char sequences with same indexes using provided [transform]. List has length of shortest char sequence. */ public inline fun CharSequence.zip(other: CharSequence, transform: (Char, Char) -> V): List { - val length = Math.min(this.length, other.length) + val length = minOf(this.length, other.length) val list = ArrayList(length) for (i in 0..length-1) { list.add(transform(this[i], other[i])) diff --git a/libraries/stdlib/common/src/kotlin/KotlinH.kt b/libraries/stdlib/common/src/kotlin/KotlinH.kt index 004b1bd7473..ac9c0cde827 100644 --- a/libraries/stdlib/common/src/kotlin/KotlinH.kt +++ b/libraries/stdlib/common/src/kotlin/KotlinH.kt @@ -74,14 +74,6 @@ internal inline header fun Array.copyToArrayOfAny(isVarargs: Boolean) internal header interface Serializable -// temporary -internal header object Math { - fun max(a: Int, b: Int): Int - fun min(a: Int, b: Int): Int -} - - - // From numbers.kt header fun Double.isNaN(): Boolean diff --git a/libraries/stdlib/src/generated/_Arrays.kt b/libraries/stdlib/src/generated/_Arrays.kt index c9ba745e2f6..d34da684667 100644 --- a/libraries/stdlib/src/generated/_Arrays.kt +++ b/libraries/stdlib/src/generated/_Arrays.kt @@ -11684,7 +11684,7 @@ public infix fun CharArray.zip(other: Array): List> { * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. */ public inline fun Array.zip(other: Array, transform: (T, R) -> V): List { - val size = Math.min(size, other.size) + val size = minOf(size, other.size) val list = ArrayList(size) for (i in 0..size-1) { list.add(transform(this[i], other[i])) @@ -11696,7 +11696,7 @@ public inline fun Array.zip(other: Array, transform: (T, * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. */ public inline fun ByteArray.zip(other: Array, transform: (Byte, R) -> V): List { - val size = Math.min(size, other.size) + val size = minOf(size, other.size) val list = ArrayList(size) for (i in 0..size-1) { list.add(transform(this[i], other[i])) @@ -11708,7 +11708,7 @@ public inline fun ByteArray.zip(other: Array, transform: (Byte, R) * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. */ public inline fun ShortArray.zip(other: Array, transform: (Short, R) -> V): List { - val size = Math.min(size, other.size) + val size = minOf(size, other.size) val list = ArrayList(size) for (i in 0..size-1) { list.add(transform(this[i], other[i])) @@ -11720,7 +11720,7 @@ public inline fun ShortArray.zip(other: Array, transform: (Short, * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. */ public inline fun IntArray.zip(other: Array, transform: (Int, R) -> V): List { - val size = Math.min(size, other.size) + val size = minOf(size, other.size) val list = ArrayList(size) for (i in 0..size-1) { list.add(transform(this[i], other[i])) @@ -11732,7 +11732,7 @@ public inline fun IntArray.zip(other: Array, transform: (Int, R) - * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. */ public inline fun LongArray.zip(other: Array, transform: (Long, R) -> V): List { - val size = Math.min(size, other.size) + val size = minOf(size, other.size) val list = ArrayList(size) for (i in 0..size-1) { list.add(transform(this[i], other[i])) @@ -11744,7 +11744,7 @@ public inline fun LongArray.zip(other: Array, transform: (Long, R) * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. */ public inline fun FloatArray.zip(other: Array, transform: (Float, R) -> V): List { - val size = Math.min(size, other.size) + val size = minOf(size, other.size) val list = ArrayList(size) for (i in 0..size-1) { list.add(transform(this[i], other[i])) @@ -11756,7 +11756,7 @@ public inline fun FloatArray.zip(other: Array, transform: (Float, * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. */ public inline fun DoubleArray.zip(other: Array, transform: (Double, R) -> V): List { - val size = Math.min(size, other.size) + val size = minOf(size, other.size) val list = ArrayList(size) for (i in 0..size-1) { list.add(transform(this[i], other[i])) @@ -11768,7 +11768,7 @@ public inline fun DoubleArray.zip(other: Array, transform: (Double * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. */ public inline fun BooleanArray.zip(other: Array, transform: (Boolean, R) -> V): List { - val size = Math.min(size, other.size) + val size = minOf(size, other.size) val list = ArrayList(size) for (i in 0..size-1) { list.add(transform(this[i], other[i])) @@ -11780,7 +11780,7 @@ public inline fun BooleanArray.zip(other: Array, transform: (Boole * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. */ public inline fun CharArray.zip(other: Array, transform: (Char, R) -> V): List { - val size = Math.min(size, other.size) + val size = minOf(size, other.size) val list = ArrayList(size) for (i in 0..size-1) { list.add(transform(this[i], other[i])) @@ -11856,7 +11856,7 @@ public infix fun CharArray.zip(other: Iterable): List> { */ public inline fun Array.zip(other: Iterable, transform: (T, R) -> V): List { val arraySize = size - val list = ArrayList(Math.min(other.collectionSizeOrDefault(10), arraySize)) + val list = ArrayList(minOf(other.collectionSizeOrDefault(10), arraySize)) var i = 0 for (element in other) { if (i >= arraySize) break @@ -11870,7 +11870,7 @@ public inline fun Array.zip(other: Iterable, transform: (T, */ public inline fun ByteArray.zip(other: Iterable, transform: (Byte, R) -> V): List { val arraySize = size - val list = ArrayList(Math.min(other.collectionSizeOrDefault(10), arraySize)) + val list = ArrayList(minOf(other.collectionSizeOrDefault(10), arraySize)) var i = 0 for (element in other) { if (i >= arraySize) break @@ -11884,7 +11884,7 @@ public inline fun ByteArray.zip(other: Iterable, transform: (Byte, R) */ public inline fun ShortArray.zip(other: Iterable, transform: (Short, R) -> V): List { val arraySize = size - val list = ArrayList(Math.min(other.collectionSizeOrDefault(10), arraySize)) + val list = ArrayList(minOf(other.collectionSizeOrDefault(10), arraySize)) var i = 0 for (element in other) { if (i >= arraySize) break @@ -11898,7 +11898,7 @@ public inline fun ShortArray.zip(other: Iterable, transform: (Short, R */ public inline fun IntArray.zip(other: Iterable, transform: (Int, R) -> V): List { val arraySize = size - val list = ArrayList(Math.min(other.collectionSizeOrDefault(10), arraySize)) + val list = ArrayList(minOf(other.collectionSizeOrDefault(10), arraySize)) var i = 0 for (element in other) { if (i >= arraySize) break @@ -11912,7 +11912,7 @@ public inline fun IntArray.zip(other: Iterable, transform: (Int, R) -> */ public inline fun LongArray.zip(other: Iterable, transform: (Long, R) -> V): List { val arraySize = size - val list = ArrayList(Math.min(other.collectionSizeOrDefault(10), arraySize)) + val list = ArrayList(minOf(other.collectionSizeOrDefault(10), arraySize)) var i = 0 for (element in other) { if (i >= arraySize) break @@ -11926,7 +11926,7 @@ public inline fun LongArray.zip(other: Iterable, transform: (Long, R) */ public inline fun FloatArray.zip(other: Iterable, transform: (Float, R) -> V): List { val arraySize = size - val list = ArrayList(Math.min(other.collectionSizeOrDefault(10), arraySize)) + val list = ArrayList(minOf(other.collectionSizeOrDefault(10), arraySize)) var i = 0 for (element in other) { if (i >= arraySize) break @@ -11940,7 +11940,7 @@ public inline fun FloatArray.zip(other: Iterable, transform: (Float, R */ public inline fun DoubleArray.zip(other: Iterable, transform: (Double, R) -> V): List { val arraySize = size - val list = ArrayList(Math.min(other.collectionSizeOrDefault(10), arraySize)) + val list = ArrayList(minOf(other.collectionSizeOrDefault(10), arraySize)) var i = 0 for (element in other) { if (i >= arraySize) break @@ -11954,7 +11954,7 @@ public inline fun DoubleArray.zip(other: Iterable, transform: (Double, */ public inline fun BooleanArray.zip(other: Iterable, transform: (Boolean, R) -> V): List { val arraySize = size - val list = ArrayList(Math.min(other.collectionSizeOrDefault(10), arraySize)) + val list = ArrayList(minOf(other.collectionSizeOrDefault(10), arraySize)) var i = 0 for (element in other) { if (i >= arraySize) break @@ -11968,7 +11968,7 @@ public inline fun BooleanArray.zip(other: Iterable, transform: (Boolea */ public inline fun CharArray.zip(other: Iterable, transform: (Char, R) -> V): List { val arraySize = size - val list = ArrayList(Math.min(other.collectionSizeOrDefault(10), arraySize)) + val list = ArrayList(minOf(other.collectionSizeOrDefault(10), arraySize)) var i = 0 for (element in other) { if (i >= arraySize) break @@ -12037,7 +12037,7 @@ public infix fun CharArray.zip(other: CharArray): List> { * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. */ public inline fun ByteArray.zip(other: ByteArray, transform: (Byte, Byte) -> V): List { - val size = Math.min(size, other.size) + val size = minOf(size, other.size) val list = ArrayList(size) for (i in 0..size-1) { list.add(transform(this[i], other[i])) @@ -12049,7 +12049,7 @@ public inline fun ByteArray.zip(other: ByteArray, transform: (Byte, Byte) -> * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. */ public inline fun ShortArray.zip(other: ShortArray, transform: (Short, Short) -> V): List { - val size = Math.min(size, other.size) + val size = minOf(size, other.size) val list = ArrayList(size) for (i in 0..size-1) { list.add(transform(this[i], other[i])) @@ -12061,7 +12061,7 @@ public inline fun ShortArray.zip(other: ShortArray, transform: (Short, Short * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. */ public inline fun IntArray.zip(other: IntArray, transform: (Int, Int) -> V): List { - val size = Math.min(size, other.size) + val size = minOf(size, other.size) val list = ArrayList(size) for (i in 0..size-1) { list.add(transform(this[i], other[i])) @@ -12073,7 +12073,7 @@ public inline fun IntArray.zip(other: IntArray, transform: (Int, Int) -> V): * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. */ public inline fun LongArray.zip(other: LongArray, transform: (Long, Long) -> V): List { - val size = Math.min(size, other.size) + val size = minOf(size, other.size) val list = ArrayList(size) for (i in 0..size-1) { list.add(transform(this[i], other[i])) @@ -12085,7 +12085,7 @@ public inline fun LongArray.zip(other: LongArray, transform: (Long, Long) -> * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. */ public inline fun FloatArray.zip(other: FloatArray, transform: (Float, Float) -> V): List { - val size = Math.min(size, other.size) + val size = minOf(size, other.size) val list = ArrayList(size) for (i in 0..size-1) { list.add(transform(this[i], other[i])) @@ -12097,7 +12097,7 @@ public inline fun FloatArray.zip(other: FloatArray, transform: (Float, Float * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. */ public inline fun DoubleArray.zip(other: DoubleArray, transform: (Double, Double) -> V): List { - val size = Math.min(size, other.size) + val size = minOf(size, other.size) val list = ArrayList(size) for (i in 0..size-1) { list.add(transform(this[i], other[i])) @@ -12109,7 +12109,7 @@ public inline fun DoubleArray.zip(other: DoubleArray, transform: (Double, Do * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. */ public inline fun BooleanArray.zip(other: BooleanArray, transform: (Boolean, Boolean) -> V): List { - val size = Math.min(size, other.size) + val size = minOf(size, other.size) val list = ArrayList(size) for (i in 0..size-1) { list.add(transform(this[i], other[i])) @@ -12121,7 +12121,7 @@ public inline fun BooleanArray.zip(other: BooleanArray, transform: (Boolean, * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. */ public inline fun CharArray.zip(other: CharArray, transform: (Char, Char) -> V): List { - val size = Math.min(size, other.size) + val size = minOf(size, other.size) val list = ArrayList(size) for (i in 0..size-1) { list.add(transform(this[i], other[i])) diff --git a/libraries/stdlib/src/generated/_Collections.kt b/libraries/stdlib/src/generated/_Collections.kt index a76a514a322..1b91dceb18f 100644 --- a/libraries/stdlib/src/generated/_Collections.kt +++ b/libraries/stdlib/src/generated/_Collections.kt @@ -1882,7 +1882,7 @@ public infix fun Iterable.zip(other: Array): List> { */ public inline fun Iterable.zip(other: Array, transform: (T, R) -> V): List { val arraySize = other.size - val list = ArrayList(Math.min(collectionSizeOrDefault(10), arraySize)) + val list = ArrayList(minOf(collectionSizeOrDefault(10), arraySize)) var i = 0 for (element in this) { if (i >= arraySize) break @@ -1904,7 +1904,7 @@ public infix fun Iterable.zip(other: Iterable): List> { public inline fun Iterable.zip(other: Iterable, transform: (T, R) -> V): List { val first = iterator() val second = other.iterator() - val list = ArrayList(Math.min(collectionSizeOrDefault(10), other.collectionSizeOrDefault(10))) + val list = ArrayList(minOf(collectionSizeOrDefault(10), other.collectionSizeOrDefault(10))) while (first.hasNext() && second.hasNext()) { list.add(transform(first.next(), second.next())) } diff --git a/libraries/stdlib/src/generated/_Strings.kt b/libraries/stdlib/src/generated/_Strings.kt index 9b3c17dd5ba..b94f1c51b4d 100644 --- a/libraries/stdlib/src/generated/_Strings.kt +++ b/libraries/stdlib/src/generated/_Strings.kt @@ -1144,7 +1144,7 @@ public infix fun CharSequence.zip(other: CharSequence): List> { * Returns a list of values built from characters of both char sequences with same indexes using provided [transform]. List has length of shortest char sequence. */ public inline fun CharSequence.zip(other: CharSequence, transform: (Char, Char) -> V): List { - val length = Math.min(this.length, other.length) + val length = minOf(this.length, other.length) val list = ArrayList(length) for (i in 0..length-1) { list.add(transform(this[i], other[i])) diff --git a/libraries/stdlib/src/kotlin/io/files/Utils.kt b/libraries/stdlib/src/kotlin/io/files/Utils.kt index bf3a11204f3..6c8cd06692a 100644 --- a/libraries/stdlib/src/kotlin/io/files/Utils.kt +++ b/libraries/stdlib/src/kotlin/io/files/Utils.kt @@ -5,6 +5,7 @@ package kotlin.io import java.io.* import java.util.* +import kotlin.comparisons.* /** * Creates an empty directory in the specified [directory], using the given [prefix] and [suffix] to generate its name. @@ -120,7 +121,7 @@ private fun File.toRelativeStringOrNull(base: File): String? { val sameCount = run countSame@ { var i = 0 - val maxSameCount = Math.min(thisCount, baseCount) + val maxSameCount = minOf(thisCount, baseCount) while (i < maxSameCount && thisComponents.segments[i] == baseComponents.segments[i]) i++ return@countSame i diff --git a/libraries/stdlib/src/kotlin/text/Strings.kt b/libraries/stdlib/src/kotlin/text/Strings.kt index 1e44fddf12d..f127507dab4 100644 --- a/libraries/stdlib/src/kotlin/text/Strings.kt +++ b/libraries/stdlib/src/kotlin/text/Strings.kt @@ -20,6 +20,8 @@ package kotlin.text +import kotlin.comparisons.* + /** * Returns a sub sequence of this char sequence having leading and trailing characters matching the [predicate] trimmed. @@ -747,7 +749,7 @@ public fun CharSequence.endsWith(suffix: CharSequence, ignoreCase: Boolean = fal * @param ignoreCase `true` to ignore character case when matching a character. By default `false`. */ public fun CharSequence.commonPrefixWith(other: CharSequence, ignoreCase: Boolean = false): String { - val shortestLength = Math.min(this.length, other.length) + val shortestLength = minOf(this.length, other.length) var i = 0 while (i < shortestLength && this[i].equals(other[i], ignoreCase = ignoreCase)) { @@ -769,7 +771,7 @@ public fun CharSequence.commonPrefixWith(other: CharSequence, ignoreCase: Boolea public fun CharSequence.commonSuffixWith(other: CharSequence, ignoreCase: Boolean = false): String { val thisLength = this.length val otherLength = other.length - val shortestLength = Math.min(thisLength, otherLength) + val shortestLength = minOf(thisLength, otherLength) var i = 0 while (i < shortestLength && this[thisLength - i - 1].equals(other[otherLength - i - 1], ignoreCase = ignoreCase)) { @@ -791,7 +793,7 @@ private fun CharSequence.findAnyOf(chars: CharArray, startIndex: Int, ignoreCase return if (index < 0) null else index to char } - val indices = if (!last) Math.max(startIndex, 0)..lastIndex else Math.min(startIndex, lastIndex) downTo 0 + val indices = if (!last) startIndex.coerceAtLeast(0)..lastIndex else startIndex.coerceAtMost(lastIndex) downTo 0 for (index in indices) { val charAtIndex = get(index) val matchingCharIndex = chars.indexOfFirst { it.equals(charAtIndex, ignoreCase) } @@ -1028,7 +1030,7 @@ private class DelimitedRangesSequence(private val input: CharSequence, private v override fun iterator(): Iterator = object : Iterator { var nextState: Int = -1 // -1 for unknown, 0 for done, 1 for continue - var currentStartIndex: Int = Math.min(Math.max(startIndex, 0), input.length) + var currentStartIndex: Int = startIndex.coerceIn(0, input.length) var nextSearchIndex: Int = currentStartIndex var nextItem: IntRange? = null var counter: Int = 0 diff --git a/libraries/stdlib/test/ranges/ProgressionLastElementTest.kt b/libraries/stdlib/test/ranges/ProgressionLastElementTest.kt index 4c6b7767d6d..e54eed274ef 100644 --- a/libraries/stdlib/test/ranges/ProgressionLastElementTest.kt +++ b/libraries/stdlib/test/ranges/ProgressionLastElementTest.kt @@ -1,6 +1,7 @@ package test.ranges import org.junit.Test +import kotlin.comparisons.* import kotlin.test.assertEquals @@ -72,7 +73,7 @@ class ProgressionLastElementTest { var x = start while (true) { val next = x + increment - if (next < Math.min(start, end) || next > Math.max(start, end)) break + if (next !in minOf(start, end)..maxOf(start, end)) break x = next } diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Generators.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Generators.kt index bae6c6e6bcf..c5a5e340045 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Generators.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Generators.kt @@ -545,7 +545,7 @@ fun generators(): List { """ val first = iterator() val second = other.iterator() - val list = ArrayList(Math.min(collectionSizeOrDefault(10), other.collectionSizeOrDefault(10))) + val list = ArrayList(minOf(collectionSizeOrDefault(10), other.collectionSizeOrDefault(10))) while (first.hasNext() && second.hasNext()) { list.add(transform(first.next(), second.next())) } @@ -555,7 +555,7 @@ fun generators(): List { body(ArraysOfObjects, ArraysOfPrimitives) { """ val arraySize = size - val list = ArrayList(Math.min(other.collectionSizeOrDefault(10), arraySize)) + val list = ArrayList(minOf(other.collectionSizeOrDefault(10), arraySize)) var i = 0 for (element in other) { if (i >= arraySize) break @@ -580,7 +580,7 @@ fun generators(): List { body { """ val arraySize = other.size - val list = ArrayList(Math.min(collectionSizeOrDefault(10), arraySize)) + val list = ArrayList(minOf(collectionSizeOrDefault(10), arraySize)) var i = 0 for (element in this) { if (i >= arraySize) break @@ -591,7 +591,7 @@ fun generators(): List { } body(ArraysOfObjects, ArraysOfPrimitives) { """ - val size = Math.min(size, other.size) + val size = minOf(size, other.size) val list = ArrayList(size) for (i in 0..size-1) { list.add(transform(this[i], other[i])) @@ -614,7 +614,7 @@ fun generators(): List { inline(true) body() { """ - val size = Math.min(size, other.size) + val size = minOf(size, other.size) val list = ArrayList(size) for (i in 0..size-1) { list.add(transform(this[i], other[i])) @@ -653,7 +653,7 @@ fun generators(): List { inline(true) body { """ - val length = Math.min(this.length, other.length) + val length = minOf(this.length, other.length) val list = ArrayList(length) for (i in 0..length-1) {