From ea943b715cbf713bc3f3baaf3215070a2b9b8861 Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Thu, 27 Dec 2018 04:50:10 +0300 Subject: [PATCH] Change implementations of contentEquals and minOf/maxOf for Native To conform to the behavior in other platforms. --- .../main/kotlin/generated/_ArraysNative.kt | 108 +++++------------- .../kotlin/generated/_ComparisonsNative.kt | 20 +--- 2 files changed, 31 insertions(+), 97 deletions(-) diff --git a/runtime/src/main/kotlin/generated/_ArraysNative.kt b/runtime/src/main/kotlin/generated/_ArraysNative.kt index 112d5ead714..74c8a5a80b9 100644 --- a/runtime/src/main/kotlin/generated/_ArraysNative.kt +++ b/runtime/src/main/kotlin/generated/_ArraysNative.kt @@ -180,16 +180,10 @@ public actual fun Array.contentDeepToString(): String { */ @SinceKotlin("1.1") public actual infix fun Array.contentEquals(other: Array): Boolean { - if (this === other) { - return true - } - if (size != other.size) { - return false - } + if (this === other) return true + if (size != other.size) return false for (i in indices) { - if (this[i] != other[i]) { - return false - } + if (this[i] != other[i]) return false } return true } @@ -200,16 +194,10 @@ public actual infix fun Array.contentEquals(other: Array): Boo */ @SinceKotlin("1.1") public actual infix fun ByteArray.contentEquals(other: ByteArray): Boolean { - if (this === other) { - return true - } - if (size != other.size) { - return false - } + if (this === other) return true + if (size != other.size) return false for (i in indices) { - if (this[i] != other[i]) { - return false - } + if (this[i] != other[i]) return false } return true } @@ -220,16 +208,10 @@ public actual infix fun ByteArray.contentEquals(other: ByteArray): Boolean { */ @SinceKotlin("1.1") public actual infix fun ShortArray.contentEquals(other: ShortArray): Boolean { - if (this === other) { - return true - } - if (size != other.size) { - return false - } + if (this === other) return true + if (size != other.size) return false for (i in indices) { - if (this[i] != other[i]) { - return false - } + if (this[i] != other[i]) return false } return true } @@ -240,16 +222,10 @@ public actual infix fun ShortArray.contentEquals(other: ShortArray): Boolean { */ @SinceKotlin("1.1") public actual infix fun IntArray.contentEquals(other: IntArray): Boolean { - if (this === other) { - return true - } - if (size != other.size) { - return false - } + if (this === other) return true + if (size != other.size) return false for (i in indices) { - if (this[i] != other[i]) { - return false - } + if (this[i] != other[i]) return false } return true } @@ -260,16 +236,10 @@ public actual infix fun IntArray.contentEquals(other: IntArray): Boolean { */ @SinceKotlin("1.1") public actual infix fun LongArray.contentEquals(other: LongArray): Boolean { - if (this === other) { - return true - } - if (size != other.size) { - return false - } + if (this === other) return true + if (size != other.size) return false for (i in indices) { - if (this[i] != other[i]) { - return false - } + if (this[i] != other[i]) return false } return true } @@ -280,16 +250,10 @@ public actual infix fun LongArray.contentEquals(other: LongArray): Boolean { */ @SinceKotlin("1.1") public actual infix fun FloatArray.contentEquals(other: FloatArray): Boolean { - if (this === other) { - return true - } - if (size != other.size) { - return false - } + if (this === other) return true + if (size != other.size) return false for (i in indices) { - if (this[i] != other[i]) { - return false - } + if (!this[i].equals(other[i])) return false } return true } @@ -300,16 +264,10 @@ public actual infix fun FloatArray.contentEquals(other: FloatArray): Boolean { */ @SinceKotlin("1.1") public actual infix fun DoubleArray.contentEquals(other: DoubleArray): Boolean { - if (this === other) { - return true - } - if (size != other.size) { - return false - } + if (this === other) return true + if (size != other.size) return false for (i in indices) { - if (this[i] != other[i]) { - return false - } + if (!this[i].equals(other[i])) return false } return true } @@ -320,16 +278,10 @@ public actual infix fun DoubleArray.contentEquals(other: DoubleArray): Boolean { */ @SinceKotlin("1.1") public actual infix fun BooleanArray.contentEquals(other: BooleanArray): Boolean { - if (this === other) { - return true - } - if (size != other.size) { - return false - } + if (this === other) return true + if (size != other.size) return false for (i in indices) { - if (this[i] != other[i]) { - return false - } + if (this[i] != other[i]) return false } return true } @@ -340,16 +292,10 @@ public actual infix fun BooleanArray.contentEquals(other: BooleanArray): Boolean */ @SinceKotlin("1.1") public actual infix fun CharArray.contentEquals(other: CharArray): Boolean { - if (this === other) { - return true - } - if (size != other.size) { - return false - } + if (this === other) return true + if (size != other.size) return false for (i in indices) { - if (this[i] != other[i]) { - return false - } + if (this[i] != other[i]) return false } return true } diff --git a/runtime/src/main/kotlin/generated/_ComparisonsNative.kt b/runtime/src/main/kotlin/generated/_ComparisonsNative.kt index 507c0f8a9f3..89d706e8ff3 100644 --- a/runtime/src/main/kotlin/generated/_ComparisonsNative.kt +++ b/runtime/src/main/kotlin/generated/_ComparisonsNative.kt @@ -62,12 +62,7 @@ public actual inline fun maxOf(a: Long, b: Long): Long { @SinceKotlin("1.1") @kotlin.internal.InlineOnly public actual inline fun maxOf(a: Float, b: Float): Float { - // TODO: Check +/-0.0 - return when { - a.isNaN() -> a - b.isNaN() -> b - else -> if (a >= b) a else b - } + return if (a.compareTo(b) >= 0) a else b } /** @@ -76,12 +71,7 @@ public actual inline fun maxOf(a: Float, b: Float): Float { @SinceKotlin("1.1") @kotlin.internal.InlineOnly public actual inline fun maxOf(a: Double, b: Double): Double { - // TODO: Check +/-0.0 - return when { - a.isNaN() -> a - b.isNaN() -> b - else -> if (a >= b) a else b - } + return if (a.compareTo(b) >= 0) a else b } /** @@ -197,11 +187,10 @@ public actual inline fun minOf(a: Long, b: Long): Long { @SinceKotlin("1.1") @kotlin.internal.InlineOnly public actual inline fun minOf(a: Float, b: Float): Float { - // TODO: Check +/-0.0 return when { a.isNaN() -> a b.isNaN() -> b - else -> if (a <= b) a else b + else -> if (a.compareTo(b) <= 0) a else b } } @@ -211,11 +200,10 @@ public actual inline fun minOf(a: Float, b: Float): Float { @SinceKotlin("1.1") @kotlin.internal.InlineOnly public actual inline fun minOf(a: Double, b: Double): Double { - // TODO: Check +/-0.0 return when { a.isNaN() -> a b.isNaN() -> b - else -> if (a <= b) a else b + else -> if (a.compareTo(b) <= 0) a else b } }