Fix CharArray sort in JS IR-backend
This commit is contained in:
@@ -1926,8 +1926,7 @@ public actual fun DoubleArray.sort(fromIndex: Int = 0, toIndex: Int = size): Uni
|
||||
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
|
||||
public actual fun CharArray.sort(fromIndex: Int = 0, toIndex: Int = size): Unit {
|
||||
AbstractList.checkRangeIndexes(fromIndex, toIndex, size)
|
||||
val subarray = this.asDynamic().subarray(fromIndex, toIndex).unsafeCast<CharArray>()
|
||||
subarray.sort()
|
||||
sortArrayWith(this.unsafeCast<Array<Char>>(), fromIndex, toIndex, naturalOrder())
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1357,21 +1357,19 @@ object ArrayOps : TemplateGroupBase() {
|
||||
"""
|
||||
}
|
||||
specialFor(ArraysOfPrimitives) {
|
||||
if (primitive != PrimitiveType.Long) {
|
||||
body {
|
||||
body {
|
||||
if (primitive == PrimitiveType.Char && target.backend == Backend.IR || primitive == PrimitiveType.Long) {
|
||||
"""
|
||||
AbstractList.checkRangeIndexes(fromIndex, toIndex, size)
|
||||
sortArrayWith(this.unsafeCast<Array<T>>(), fromIndex, toIndex, naturalOrder())
|
||||
"""
|
||||
} else {
|
||||
"""
|
||||
AbstractList.checkRangeIndexes(fromIndex, toIndex, size)
|
||||
val subarray = this.asDynamic().subarray(fromIndex, toIndex).unsafeCast<SELF>()
|
||||
subarray.sort()
|
||||
"""
|
||||
}
|
||||
} else {
|
||||
body {
|
||||
"""
|
||||
AbstractList.checkRangeIndexes(fromIndex, toIndex, size)
|
||||
sortArrayWith(this.unsafeCast<Array<Long>>(), fromIndex, toIndex, naturalOrder())
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user