[Wasm] Improve string constructor in stdlib
This commit is contained in:
@@ -12,8 +12,11 @@ import kotlin.math.min
|
||||
* The `String` class represents character strings. All string literals in Kotlin programs, such as `"abc"`, are
|
||||
* implemented as instances of this class.
|
||||
*/
|
||||
public class String internal constructor(internal val chars: CharArray) : Comparable<String>, CharSequence {
|
||||
public companion object;
|
||||
public class String private constructor(internal val chars: CharArray) : Comparable<String>, CharSequence {
|
||||
public companion object {
|
||||
// Note: doesn't copy the array, use with care.
|
||||
internal fun unsafeFromCharArray(chars: CharArray) = String(chars)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string obtained by concatenating this string with the string representation of the given [other] object.
|
||||
@@ -68,4 +71,4 @@ public class String internal constructor(internal val chars: CharArray) : Compar
|
||||
}
|
||||
}
|
||||
|
||||
internal fun stringLiteral(startAddr: Int, length: Int) = String(unsafeRawMemoryToCharArray(startAddr, length))
|
||||
internal fun stringLiteral(startAddr: Int, length: Int) = String.unsafeFromCharArray(unsafeRawMemoryToCharArray(startAddr, length))
|
||||
|
||||
Reference in New Issue
Block a user