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:12 +03:00
parent a951805218
commit a26aa30714
2 changed files with 9 additions and 17 deletions
@@ -99,18 +99,16 @@ object ArrayOps : TemplateGroupBase() {
} }
} }
on(Platform.Native) { on(Platform.Native) {
fun notEq(operand1: String, operand2: String) = when {
primitive?.isFloatingPoint() == true -> "!$operand1.equals($operand2)"
else -> "$operand1 != $operand2"
}
body { body {
""" """
if (this === other) { if (this === other) return true
return true if (size != other.size) return false
}
if (size != other.size) {
return false
}
for (i in indices) { for (i in indices) {
if (this[i] != other[i]) { if (${notEq("this[i]", "other[i]")}) return false
return false
}
} }
return true return true
""" """
@@ -178,11 +178,10 @@ object ComparableOps : TemplateGroupBase() {
on(Platform.Native) { on(Platform.Native) {
body { body {
""" """
// TODO: Check +/-0.0
return when { return when {
a.isNaN() -> a a.isNaN() -> a
b.isNaN() -> b b.isNaN() -> b
else -> $defaultImpl else -> if (a.compareTo(b) <= 0) a else b
} }
""" """
} }
@@ -318,12 +317,7 @@ object ComparableOps : TemplateGroupBase() {
on(Platform.Native) { on(Platform.Native) {
body { body {
""" """
// TODO: Check +/-0.0 return if (a.compareTo(b) >= 0) a else b
return when {
a.isNaN() -> a
b.isNaN() -> b
else -> $defaultImpl
}
""" """
} }
} }