Change implementations of contentEquals and minOf/maxOf for Native

To conform to the behavior in other platforms.
This commit is contained in:
Ilya Gorbunov
2018-12-27 04:50:10 +03:00
committed by Pavel Punegov
parent 53838e39c8
commit ea943b715c
2 changed files with 31 additions and 97 deletions
@@ -180,16 +180,10 @@ public actual fun <T> Array<out T>.contentDeepToString(): String {
*/
@SinceKotlin("1.1")
public actual infix fun <T> Array<out T>.contentEquals(other: Array<out T>): 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 <T> Array<out T>.contentEquals(other: Array<out T>): 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
}
@@ -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
}
}