Provide Common StringBuilder.append/insert with primitive type arguments #KT-57359

Merge-request: KT-MR-10892
Merged-by: Abduqodiri Qurbonzoda <abduqodiri.qurbonzoda@jetbrains.com>
This commit is contained in:
Abduqodiri Qurbonzoda
2023-07-13 11:52:14 +00:00
committed by Space Team
parent 2d50bd6857
commit fed453fdea
7 changed files with 508 additions and 26 deletions
@@ -10,32 +10,32 @@ import kotlin.native.internal.GCUnsafeCall
/** Appends [value] to this [StringBuilder], followed by a line feed character (`\n`). */
@SinceKotlin("1.4")
@kotlin.internal.InlineOnly
public inline fun StringBuilder.appendLine(value: Byte): StringBuilder = append(value).appendLine()
public actual inline fun StringBuilder.appendLine(value: Byte): StringBuilder = append(value).appendLine()
/** Appends [value] to this [StringBuilder], followed by a line feed character (`\n`). */
@SinceKotlin("1.4")
@kotlin.internal.InlineOnly
public inline fun StringBuilder.appendLine(value: Short): StringBuilder = append(value).appendLine()
public actual inline fun StringBuilder.appendLine(value: Short): StringBuilder = append(value).appendLine()
/** Appends [value] to this [StringBuilder], followed by a line feed character (`\n`). */
@SinceKotlin("1.4")
@kotlin.internal.InlineOnly
public inline fun StringBuilder.appendLine(value: Int): StringBuilder = append(value).appendLine()
public actual inline fun StringBuilder.appendLine(value: Int): StringBuilder = append(value).appendLine()
/** Appends [value] to this [StringBuilder], followed by a line feed character (`\n`). */
@SinceKotlin("1.4")
@kotlin.internal.InlineOnly
public inline fun StringBuilder.appendLine(value: Long): StringBuilder = append(value).appendLine()
public actual inline fun StringBuilder.appendLine(value: Long): StringBuilder = append(value).appendLine()
/** Appends [value] to this [StringBuilder], followed by a line feed character (`\n`). */
@SinceKotlin("1.4")
@kotlin.internal.InlineOnly
public inline fun StringBuilder.appendLine(value: Float): StringBuilder = append(value).appendLine()
public actual inline fun StringBuilder.appendLine(value: Float): StringBuilder = append(value).appendLine()
/** Appends [value] to this [StringBuilder], followed by a line feed character (`\n`). */
@SinceKotlin("1.4")
@kotlin.internal.InlineOnly
public inline fun StringBuilder.appendLine(value: Double): StringBuilder = append(value).appendLine()
public actual inline fun StringBuilder.appendLine(value: Double): StringBuilder = append(value).appendLine()
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.6")
+60
View File
@@ -74,6 +74,10 @@ public inline fun kotlin.text.StringBuilder.appendLine(value: kotlin.Any?): kotl
@kotlin.internal.InlineOnly
public inline fun kotlin.text.StringBuilder.appendLine(value: kotlin.Boolean): kotlin.text.StringBuilder
@kotlin.SinceKotlin(version = "1.9")
@kotlin.internal.InlineOnly
public inline fun kotlin.text.StringBuilder.appendLine(value: kotlin.Byte): kotlin.text.StringBuilder
@kotlin.SinceKotlin(version = "1.4")
@kotlin.internal.InlineOnly
public inline fun kotlin.text.StringBuilder.appendLine(value: kotlin.Char): kotlin.text.StringBuilder
@@ -86,6 +90,26 @@ public inline fun kotlin.text.StringBuilder.appendLine(value: kotlin.CharArray):
@kotlin.internal.InlineOnly
public inline fun kotlin.text.StringBuilder.appendLine(value: kotlin.CharSequence?): kotlin.text.StringBuilder
@kotlin.SinceKotlin(version = "1.9")
@kotlin.internal.InlineOnly
public inline fun kotlin.text.StringBuilder.appendLine(value: kotlin.Double): kotlin.text.StringBuilder
@kotlin.SinceKotlin(version = "1.9")
@kotlin.internal.InlineOnly
public inline fun kotlin.text.StringBuilder.appendLine(value: kotlin.Float): kotlin.text.StringBuilder
@kotlin.SinceKotlin(version = "1.9")
@kotlin.internal.InlineOnly
public inline fun kotlin.text.StringBuilder.appendLine(value: kotlin.Int): kotlin.text.StringBuilder
@kotlin.SinceKotlin(version = "1.9")
@kotlin.internal.InlineOnly
public inline fun kotlin.text.StringBuilder.appendLine(value: kotlin.Long): kotlin.text.StringBuilder
@kotlin.SinceKotlin(version = "1.9")
@kotlin.internal.InlineOnly
public inline fun kotlin.text.StringBuilder.appendLine(value: kotlin.Short): kotlin.text.StringBuilder
@kotlin.SinceKotlin(version = "1.4")
@kotlin.internal.InlineOnly
public inline fun kotlin.text.StringBuilder.appendLine(value: kotlin.String?): kotlin.text.StringBuilder
@@ -1665,6 +1689,9 @@ public final class StringBuilder : kotlin.text.Appendable, kotlin.CharSequence {
@kotlin.SinceKotlin(version = "1.3")
public final fun append(value: kotlin.Boolean): kotlin.text.StringBuilder
@kotlin.SinceKotlin(version = "1.9")
public final fun append(value: kotlin.Byte): kotlin.text.StringBuilder
public open override fun append(value: kotlin.Char): kotlin.text.StringBuilder
@kotlin.SinceKotlin(version = "1.4")
@@ -1675,6 +1702,21 @@ public final class StringBuilder : kotlin.text.Appendable, kotlin.CharSequence {
public open override fun append(value: kotlin.CharSequence?, startIndex: kotlin.Int, endIndex: kotlin.Int): kotlin.text.StringBuilder
@kotlin.SinceKotlin(version = "1.9")
public final fun append(value: kotlin.Double): kotlin.text.StringBuilder
@kotlin.SinceKotlin(version = "1.9")
public final fun append(value: kotlin.Float): kotlin.text.StringBuilder
@kotlin.SinceKotlin(version = "1.9")
public final fun append(value: kotlin.Int): kotlin.text.StringBuilder
@kotlin.SinceKotlin(version = "1.9")
public final fun append(value: kotlin.Long): kotlin.text.StringBuilder
@kotlin.SinceKotlin(version = "1.9")
public final fun append(value: kotlin.Short): kotlin.text.StringBuilder
@kotlin.SinceKotlin(version = "1.3")
public final fun append(value: kotlin.String?): kotlin.text.StringBuilder
@@ -1723,6 +1765,9 @@ public final class StringBuilder : kotlin.text.Appendable, kotlin.CharSequence {
@kotlin.WasExperimental(markerClass = {kotlin.ExperimentalStdlibApi::class})
public final fun insert(index: kotlin.Int, value: kotlin.Boolean): kotlin.text.StringBuilder
@kotlin.SinceKotlin(version = "1.9")
public final fun insert(index: kotlin.Int, value: kotlin.Byte): kotlin.text.StringBuilder
@kotlin.SinceKotlin(version = "1.4")
@kotlin.WasExperimental(markerClass = {kotlin.ExperimentalStdlibApi::class})
public final fun insert(index: kotlin.Int, value: kotlin.Char): kotlin.text.StringBuilder
@@ -1735,6 +1780,21 @@ public final class StringBuilder : kotlin.text.Appendable, kotlin.CharSequence {
@kotlin.WasExperimental(markerClass = {kotlin.ExperimentalStdlibApi::class})
public final fun insert(index: kotlin.Int, value: kotlin.CharSequence?): kotlin.text.StringBuilder
@kotlin.SinceKotlin(version = "1.9")
public final fun insert(index: kotlin.Int, value: kotlin.Double): kotlin.text.StringBuilder
@kotlin.SinceKotlin(version = "1.9")
public final fun insert(index: kotlin.Int, value: kotlin.Float): kotlin.text.StringBuilder
@kotlin.SinceKotlin(version = "1.9")
public final fun insert(index: kotlin.Int, value: kotlin.Int): kotlin.text.StringBuilder
@kotlin.SinceKotlin(version = "1.9")
public final fun insert(index: kotlin.Int, value: kotlin.Long): kotlin.text.StringBuilder
@kotlin.SinceKotlin(version = "1.9")
public final fun insert(index: kotlin.Int, value: kotlin.Short): kotlin.text.StringBuilder
@kotlin.SinceKotlin(version = "1.4")
@kotlin.WasExperimental(markerClass = {kotlin.ExperimentalStdlibApi::class})
public final fun insert(index: kotlin.Int, value: kotlin.String?): kotlin.text.StringBuilder
@@ -100,6 +100,60 @@ public actual class StringBuilder actual constructor(content: String) : Appendab
return this
}
/**
* Appends the string representation of the specified byte [value] to this string builder and returns this instance.
*
* The overall effect is exactly as if the [value] were converted to a string by the `value.toString()` method,
* and then that string was appended to this string builder.
*/
@SinceKotlin("1.9")
actual fun append(value: Byte): StringBuilder = append(value.toString())
/**
* Appends the string representation of the specified short [value] to this string builder and returns this instance.
*
* The overall effect is exactly as if the [value] were converted to a string by the `value.toString()` method,
* and then that string was appended to this string builder.
*/
@SinceKotlin("1.9")
actual fun append(value: Short): StringBuilder = append(value.toString())
/**
* Appends the string representation of the specified int [value] to this string builder and returns this instance.
*
* The overall effect is exactly as if the [value] were converted to a string by the `value.toString()` method,
* and then that string was appended to this string builder.
*/
@SinceKotlin("1.9")
actual fun append(value: Int): StringBuilder = append(value.toString())
/**
* Appends the string representation of the specified long [value] to this string builder and returns this instance.
*
* The overall effect is exactly as if the [value] were converted to a string by the `value.toString()` method,
* and then that string was appended to this string builder.
*/
@SinceKotlin("1.9")
actual fun append(value: Long): StringBuilder = append(value.toString())
/**
* Appends the string representation of the specified float [value] to this string builder and returns this instance.
*
* The overall effect is exactly as if the [value] were converted to a string by the `value.toString()` method,
* and then that string was appended to this string builder.
*/
@SinceKotlin("1.9")
actual fun append(value: Float): StringBuilder = append(value.toString())
/**
* Appends the string representation of the specified double [value] to this string builder and returns this instance.
*
* The overall effect is exactly as if the [value] were converted to a string by the `value.toString()` method,
* and then that string was appended to this string builder.
*/
@SinceKotlin("1.9")
actual fun append(value: Double): StringBuilder = append(value.toString())
/**
* Appends characters in the specified character array [value] to this string builder and returns this instance.
*
@@ -208,6 +262,72 @@ public actual class StringBuilder actual constructor(content: String) : Appendab
return this
}
/**
* Inserts the string representation of the specified byte [value] into this string builder at the specified [index] and returns this instance.
*
* The overall effect is exactly as if the [value] were converted to a string by the `value.toString()` method,
* and then that string was inserted into this string builder at the specified [index].
*
* @throws IndexOutOfBoundsException if [index] is less than zero or greater than the length of this string builder.
*/
@SinceKotlin("1.9")
actual fun insert(index: Int, value: Byte): StringBuilder = insert(index, value.toString())
/**
* Inserts the string representation of the specified short [value] into this string builder at the specified [index] and returns this instance.
*
* The overall effect is exactly as if the [value] were converted to a string by the `value.toString()` method,
* and then that string was inserted into this string builder at the specified [index].
*
* @throws IndexOutOfBoundsException if [index] is less than zero or greater than the length of this string builder.
*/
@SinceKotlin("1.9")
actual fun insert(index: Int, value: Short): StringBuilder = insert(index, value.toString())
/**
* Inserts the string representation of the specified int [value] into this string builder at the specified [index] and returns this instance.
*
* The overall effect is exactly as if the [value] were converted to a string by the `value.toString()` method,
* and then that string was inserted into this string builder at the specified [index].
*
* @throws IndexOutOfBoundsException if [index] is less than zero or greater than the length of this string builder.
*/
@SinceKotlin("1.9")
actual fun insert(index: Int, value: Int): StringBuilder = insert(index, value.toString())
/**
* Inserts the string representation of the specified long [value] into this string builder at the specified [index] and returns this instance.
*
* The overall effect is exactly as if the [value] were converted to a string by the `value.toString()` method,
* and then that string was inserted into this string builder at the specified [index].
*
* @throws IndexOutOfBoundsException if [index] is less than zero or greater than the length of this string builder.
*/
@SinceKotlin("1.9")
actual fun insert(index: Int, value: Long): StringBuilder = insert(index, value.toString())
/**
* Inserts the string representation of the specified float [value] into this string builder at the specified [index] and returns this instance.
*
* The overall effect is exactly as if the [value] were converted to a string by the `value.toString()` method,
* and then that string was inserted into this string builder at the specified [index].
*
* @throws IndexOutOfBoundsException if [index] is less than zero or greater than the length of this string builder.
*/
@SinceKotlin("1.9")
actual fun insert(index: Int, value: Float): StringBuilder = insert(index, value.toString())
/**
* Inserts the string representation of the specified double [value] into this string builder at the specified [index] and returns this instance.
*
* The overall effect is exactly as if the [value] were converted to a string by the `value.toString()` method,
* and then that string was inserted into this string builder at the specified [index].
*
* @throws IndexOutOfBoundsException if [index] is less than zero or greater than the length of this string builder.
*/
@SinceKotlin("1.9")
actual fun insert(index: Int, value: Double): StringBuilder = insert(index, value.toString())
/**
* Inserts the specified character [value] into this string builder at the specified [index] and returns this instance.
*
@@ -704,3 +824,33 @@ public actual inline fun StringBuilder.insertRange(index: Int, value: CharArray,
@Suppress("EXTENSION_SHADOWED_BY_MEMBER", "NOTHING_TO_INLINE")
public actual inline fun StringBuilder.insertRange(index: Int, value: CharSequence, startIndex: Int, endIndex: Int): StringBuilder =
this.insertRange(index, value, startIndex, endIndex)
/** Appends [value] to this [StringBuilder], followed by a line feed character (`\n`). */
@SinceKotlin("1.9")
@kotlin.internal.InlineOnly
public actual inline fun StringBuilder.appendLine(value: Int): StringBuilder = append(value).appendLine()
/** Appends [value] to this [StringBuilder], followed by a line feed character (`\n`). */
@SinceKotlin("1.9")
@kotlin.internal.InlineOnly
public actual inline fun StringBuilder.appendLine(value: Short): StringBuilder = append(value.toInt()).appendLine()
/** Appends [value] to this [StringBuilder], followed by a line feed character (`\n`). */
@SinceKotlin("1.9")
@kotlin.internal.InlineOnly
public actual inline fun StringBuilder.appendLine(value: Byte): StringBuilder = append(value.toInt()).appendLine()
/** Appends [value] to this [StringBuilder], followed by a line feed character (`\n`). */
@SinceKotlin("1.9")
@kotlin.internal.InlineOnly
public actual inline fun StringBuilder.appendLine(value: Long): StringBuilder = append(value).appendLine()
/** Appends [value] to this [StringBuilder], followed by a line feed character (`\n`). */
@SinceKotlin("1.9")
@kotlin.internal.InlineOnly
public actual inline fun StringBuilder.appendLine(value: Float): StringBuilder = append(value).appendLine()
/** Appends [value] to this [StringBuilder], followed by a line feed character (`\n`). */
@SinceKotlin("1.9")
@kotlin.internal.InlineOnly
public actual inline fun StringBuilder.appendLine(value: Double): StringBuilder = append(value).appendLine()
@@ -169,32 +169,32 @@ public inline fun StringBuilder.appendLine(value: StringBuilder?): StringBuilder
/** Appends [value] to this [StringBuilder], followed by a line feed character (`\n`). */
@SinceKotlin("1.4")
@kotlin.internal.InlineOnly
public inline fun StringBuilder.appendLine(value: Int): StringBuilder = append(value).appendLine()
public actual inline fun StringBuilder.appendLine(value: Int): StringBuilder = append(value).appendLine()
/** Appends [value] to this [StringBuilder], followed by a line feed character (`\n`). */
@SinceKotlin("1.4")
@kotlin.internal.InlineOnly
public inline fun StringBuilder.appendLine(value: Short): StringBuilder = append(value.toInt()).appendLine()
public actual inline fun StringBuilder.appendLine(value: Short): StringBuilder = append(value.toInt()).appendLine()
/** Appends [value] to this [StringBuilder], followed by a line feed character (`\n`). */
@SinceKotlin("1.4")
@kotlin.internal.InlineOnly
public inline fun StringBuilder.appendLine(value: Byte): StringBuilder = append(value.toInt()).appendLine()
public actual inline fun StringBuilder.appendLine(value: Byte): StringBuilder = append(value.toInt()).appendLine()
/** Appends [value] to this [StringBuilder], followed by a line feed character (`\n`). */
@SinceKotlin("1.4")
@kotlin.internal.InlineOnly
public inline fun StringBuilder.appendLine(value: Long): StringBuilder = append(value).appendLine()
public actual inline fun StringBuilder.appendLine(value: Long): StringBuilder = append(value).appendLine()
/** Appends [value] to this [StringBuilder], followed by a line feed character (`\n`). */
@SinceKotlin("1.4")
@kotlin.internal.InlineOnly
public inline fun StringBuilder.appendLine(value: Float): StringBuilder = append(value).appendLine()
public actual inline fun StringBuilder.appendLine(value: Float): StringBuilder = append(value).appendLine()
/** Appends [value] to this [StringBuilder], followed by a line feed character (`\n`). */
@SinceKotlin("1.4")
@kotlin.internal.InlineOnly
public inline fun StringBuilder.appendLine(value: Double): StringBuilder = append(value).appendLine()
public actual inline fun StringBuilder.appendLine(value: Double): StringBuilder = append(value).appendLine()
private object SystemProperties {
@@ -142,24 +142,67 @@ actual class StringBuilder private constructor (
*/
actual fun append(value: Any?): StringBuilder = append(value.toString())
// TODO: optimize the append overloads with primitive value!
/**
* Appends the string representation of the specified boolean [value] to this string builder and returns this instance.
*
* The overall effect is exactly as if the [value] were converted to a string by the `value.toString()` method,
* and then that string was appended to this string builder.
*/
// TODO: optimize those!
actual fun append(value: Boolean): StringBuilder = append(value.toString())
fun append(value: Byte): StringBuilder = append(value.toString())
fun append(value: Short): StringBuilder = append(value.toString())
fun append(value: Int): StringBuilder {
/**
* Appends the string representation of the specified byte [value] to this string builder and returns this instance.
*
* The overall effect is exactly as if the [value] were converted to a string by the `value.toString()` method,
* and then that string was appended to this string builder.
*/
actual fun append(value: Byte): StringBuilder = append(value.toString())
/**
* Appends the string representation of the specified short [value] to this string builder and returns this instance.
*
* The overall effect is exactly as if the [value] were converted to a string by the `value.toString()` method,
* and then that string was appended to this string builder.
*/
actual fun append(value: Short): StringBuilder = append(value.toString())
/**
* Appends the string representation of the specified int [value] to this string builder and returns this instance.
*
* The overall effect is exactly as if the [value] were converted to a string by the `value.toString()` method,
* and then that string was appended to this string builder.
*/
actual fun append(value: Int): StringBuilder {
ensureExtraCapacity(11)
_length += insertInt(array, _length, value)
return this
}
fun append(value: Long): StringBuilder = append(value.toString())
fun append(value: Float): StringBuilder = append(value.toString())
fun append(value: Double): StringBuilder = append(value.toString())
/**
* Appends the string representation of the specified long [value] to this string builder and returns this instance.
*
* The overall effect is exactly as if the [value] were converted to a string by the `value.toString()` method,
* and then that string was appended to this string builder.
*/
actual fun append(value: Long): StringBuilder = append(value.toString())
/**
* Appends the string representation of the specified float [value] to this string builder and returns this instance.
*
* The overall effect is exactly as if the [value] were converted to a string by the `value.toString()` method,
* and then that string was appended to this string builder.
*/
actual fun append(value: Float): StringBuilder = append(value.toString())
/**
* Appends the string representation of the specified double [value] to this string builder and returns this instance.
*
* The overall effect is exactly as if the [value] were converted to a string by the `value.toString()` method,
* and then that string was appended to this string builder.
*/
actual fun append(value: Double): StringBuilder = append(value.toString())
/**
* Appends characters in the specified character array [value] to this string builder and returns this instance.
@@ -253,6 +296,8 @@ actual class StringBuilder private constructor (
return (this as CharSequence).lastIndexOf(string, startIndex, ignoreCase = false)
}
// TODO: optimize the insert overloads with primitive value!
/**
* Inserts the string representation of the specified boolean [value] into this string builder at the specified [index] and returns this instance.
*
@@ -261,14 +306,67 @@ actual class StringBuilder private constructor (
*
* @throws IndexOutOfBoundsException if [index] is less than zero or greater than the length of this string builder.
*/
// TODO: optimize those!
actual fun insert(index: Int, value: Boolean): StringBuilder = insert(index, value.toString())
fun insert(index: Int, value: Byte) = insert(index, value.toString())
fun insert(index: Int, value: Short) = insert(index, value.toString())
fun insert(index: Int, value: Int) = insert(index, value.toString())
fun insert(index: Int, value: Long) = insert(index, value.toString())
fun insert(index: Int, value: Float) = insert(index, value.toString())
fun insert(index: Int, value: Double) = insert(index, value.toString())
/**
* Inserts the string representation of the specified byte [value] into this string builder at the specified [index] and returns this instance.
*
* The overall effect is exactly as if the [value] were converted to a string by the `value.toString()` method,
* and then that string was inserted into this string builder at the specified [index].
*
* @throws IndexOutOfBoundsException if [index] is less than zero or greater than the length of this string builder.
*/
actual fun insert(index: Int, value: Byte): StringBuilder = insert(index, value.toString())
/**
* Inserts the string representation of the specified short [value] into this string builder at the specified [index] and returns this instance.
*
* The overall effect is exactly as if the [value] were converted to a string by the `value.toString()` method,
* and then that string was inserted into this string builder at the specified [index].
*
* @throws IndexOutOfBoundsException if [index] is less than zero or greater than the length of this string builder.
*/
actual fun insert(index: Int, value: Short): StringBuilder = insert(index, value.toString())
/**
* Inserts the string representation of the specified int [value] into this string builder at the specified [index] and returns this instance.
*
* The overall effect is exactly as if the [value] were converted to a string by the `value.toString()` method,
* and then that string was inserted into this string builder at the specified [index].
*
* @throws IndexOutOfBoundsException if [index] is less than zero or greater than the length of this string builder.
*/
actual fun insert(index: Int, value: Int): StringBuilder = insert(index, value.toString())
/**
* Inserts the string representation of the specified long [value] into this string builder at the specified [index] and returns this instance.
*
* The overall effect is exactly as if the [value] were converted to a string by the `value.toString()` method,
* and then that string was inserted into this string builder at the specified [index].
*
* @throws IndexOutOfBoundsException if [index] is less than zero or greater than the length of this string builder.
*/
actual fun insert(index: Int, value: Long): StringBuilder = insert(index, value.toString())
/**
* Inserts the string representation of the specified float [value] into this string builder at the specified [index] and returns this instance.
*
* The overall effect is exactly as if the [value] were converted to a string by the `value.toString()` method,
* and then that string was inserted into this string builder at the specified [index].
*
* @throws IndexOutOfBoundsException if [index] is less than zero or greater than the length of this string builder.
*/
actual fun insert(index: Int, value: Float): StringBuilder = insert(index, value.toString())
/**
* Inserts the string representation of the specified double [value] into this string builder at the specified [index] and returns this instance.
*
* The overall effect is exactly as if the [value] were converted to a string by the `value.toString()` method,
* and then that string was inserted into this string builder at the specified [index].
*
* @throws IndexOutOfBoundsException if [index] is less than zero or greater than the length of this string builder.
*/
actual fun insert(index: Int, value: Double): StringBuilder = insert(index, value.toString())
/**
* Inserts the specified character [value] into this string builder at the specified [index] and returns this instance.
@@ -69,6 +69,60 @@ expect class StringBuilder : Appendable, CharSequence {
@SinceKotlin("1.3")
fun append(value: Boolean): StringBuilder
/**
* Appends the string representation of the specified byte [value] to this string builder and returns this instance.
*
* The overall effect is exactly as if the [value] were converted to a string by the `value.toString()` method,
* and then that string was appended to this string builder.
*/
@SinceKotlin("1.9")
fun append(value: Byte): StringBuilder
/**
* Appends the string representation of the specified short [value] to this string builder and returns this instance.
*
* The overall effect is exactly as if the [value] were converted to a string by the `value.toString()` method,
* and then that string was appended to this string builder.
*/
@SinceKotlin("1.9")
fun append(value: Short): StringBuilder
/**
* Appends the string representation of the specified int [value] to this string builder and returns this instance.
*
* The overall effect is exactly as if the [value] were converted to a string by the `value.toString()` method,
* and then that string was appended to this string builder.
*/
@SinceKotlin("1.9")
fun append(value: Int): StringBuilder
/**
* Appends the string representation of the specified long [value] to this string builder and returns this instance.
*
* The overall effect is exactly as if the [value] were converted to a string by the `value.toString()` method,
* and then that string was appended to this string builder.
*/
@SinceKotlin("1.9")
fun append(value: Long): StringBuilder
/**
* Appends the string representation of the specified float [value] to this string builder and returns this instance.
*
* The overall effect is exactly as if the [value] were converted to a string by the `value.toString()` method,
* and then that string was appended to this string builder.
*/
@SinceKotlin("1.9")
fun append(value: Float): StringBuilder
/**
* Appends the string representation of the specified double [value] to this string builder and returns this instance.
*
* The overall effect is exactly as if the [value] were converted to a string by the `value.toString()` method,
* and then that string was appended to this string builder.
*/
@SinceKotlin("1.9")
fun append(value: Double): StringBuilder
/**
* Appends characters in the specified character array [value] to this string builder and returns this instance.
*
@@ -157,6 +211,72 @@ expect class StringBuilder : Appendable, CharSequence {
@WasExperimental(ExperimentalStdlibApi::class)
fun insert(index: Int, value: Boolean): StringBuilder
/**
* Inserts the string representation of the specified byte [value] into this string builder at the specified [index] and returns this instance.
*
* The overall effect is exactly as if the [value] were converted to a string by the `value.toString()` method,
* and then that string was inserted into this string builder at the specified [index].
*
* @throws IndexOutOfBoundsException if [index] is less than zero or greater than the length of this string builder.
*/
@SinceKotlin("1.9")
fun insert(index: Int, value: Byte): StringBuilder
/**
* Inserts the string representation of the specified short [value] into this string builder at the specified [index] and returns this instance.
*
* The overall effect is exactly as if the [value] were converted to a string by the `value.toString()` method,
* and then that string was inserted into this string builder at the specified [index].
*
* @throws IndexOutOfBoundsException if [index] is less than zero or greater than the length of this string builder.
*/
@SinceKotlin("1.9")
fun insert(index: Int, value: Short): StringBuilder
/**
* Inserts the string representation of the specified int [value] into this string builder at the specified [index] and returns this instance.
*
* The overall effect is exactly as if the [value] were converted to a string by the `value.toString()` method,
* and then that string was inserted into this string builder at the specified [index].
*
* @throws IndexOutOfBoundsException if [index] is less than zero or greater than the length of this string builder.
*/
@SinceKotlin("1.9")
fun insert(index: Int, value: Int): StringBuilder
/**
* Inserts the string representation of the specified long [value] into this string builder at the specified [index] and returns this instance.
*
* The overall effect is exactly as if the [value] were converted to a string by the `value.toString()` method,
* and then that string was inserted into this string builder at the specified [index].
*
* @throws IndexOutOfBoundsException if [index] is less than zero or greater than the length of this string builder.
*/
@SinceKotlin("1.9")
fun insert(index: Int, value: Long): StringBuilder
/**
* Inserts the string representation of the specified float [value] into this string builder at the specified [index] and returns this instance.
*
* The overall effect is exactly as if the [value] were converted to a string by the `value.toString()` method,
* and then that string was inserted into this string builder at the specified [index].
*
* @throws IndexOutOfBoundsException if [index] is less than zero or greater than the length of this string builder.
*/
@SinceKotlin("1.9")
fun insert(index: Int, value: Float): StringBuilder
/**
* Inserts the string representation of the specified double [value] into this string builder at the specified [index] and returns this instance.
*
* The overall effect is exactly as if the [value] were converted to a string by the `value.toString()` method,
* and then that string was inserted into this string builder at the specified [index].
*
* @throws IndexOutOfBoundsException if [index] is less than zero or greater than the length of this string builder.
*/
@SinceKotlin("1.9")
fun insert(index: Int, value: Double): StringBuilder
/**
* Inserts the specified character [value] into this string builder at the specified [index] and returns this instance.
*
@@ -477,3 +597,27 @@ public inline fun StringBuilder.appendLine(value: Char): StringBuilder = append(
@SinceKotlin("1.4")
@kotlin.internal.InlineOnly
public inline fun StringBuilder.appendLine(value: Boolean): StringBuilder = append(value).appendLine()
/** Appends [value] to this [StringBuilder], followed by a line feed character (`\n`). */
@SinceKotlin("1.9")
public expect fun StringBuilder.appendLine(value: Byte): StringBuilder
/** Appends [value] to this [StringBuilder], followed by a line feed character (`\n`). */
@SinceKotlin("1.9")
public expect fun StringBuilder.appendLine(value: Short): StringBuilder
/** Appends [value] to this [StringBuilder], followed by a line feed character (`\n`). */
@SinceKotlin("1.9")
public expect fun StringBuilder.appendLine(value: Int): StringBuilder
/** Appends [value] to this [StringBuilder], followed by a line feed character (`\n`). */
@SinceKotlin("1.9")
public expect fun StringBuilder.appendLine(value: Long): StringBuilder
/** Appends [value] to this [StringBuilder], followed by a line feed character (`\n`). */
@SinceKotlin("1.9")
public expect fun StringBuilder.appendLine(value: Float): StringBuilder
/** Appends [value] to this [StringBuilder], followed by a line feed character (`\n`). */
@SinceKotlin("1.9")
public expect fun StringBuilder.appendLine(value: Double): StringBuilder
@@ -7,6 +7,36 @@ package kotlin.text
import kotlin.wasm.internal.*
/** Appends [value] to this [StringBuilder], followed by a line feed character (`\n`). */
@SinceKotlin("1.9")
@kotlin.internal.InlineOnly
public actual inline fun StringBuilder.appendLine(value: Byte): StringBuilder = append(value).appendLine()
/** Appends [value] to this [StringBuilder], followed by a line feed character (`\n`). */
@SinceKotlin("1.9")
@kotlin.internal.InlineOnly
public actual inline fun StringBuilder.appendLine(value: Short): StringBuilder = append(value).appendLine()
/** Appends [value] to this [StringBuilder], followed by a line feed character (`\n`). */
@SinceKotlin("1.9")
@kotlin.internal.InlineOnly
public actual inline fun StringBuilder.appendLine(value: Int): StringBuilder = append(value).appendLine()
/** Appends [value] to this [StringBuilder], followed by a line feed character (`\n`). */
@SinceKotlin("1.9")
@kotlin.internal.InlineOnly
public actual inline fun StringBuilder.appendLine(value: Long): StringBuilder = append(value).appendLine()
/** Appends [value] to this [StringBuilder], followed by a line feed character (`\n`). */
@SinceKotlin("1.9")
@kotlin.internal.InlineOnly
public actual inline fun StringBuilder.appendLine(value: Float): StringBuilder = append(value).appendLine()
/** Appends [value] to this [StringBuilder], followed by a line feed character (`\n`). */
@SinceKotlin("1.9")
@kotlin.internal.InlineOnly
public actual inline fun StringBuilder.appendLine(value: Double): StringBuilder = append(value).appendLine()
internal fun insertString(array: CharArray, destinationIndex: Int, value: String, sourceIndex: Int, count: Int): Int {
copyWasmArray(value.chars, array.storage, sourceIndex, destinationIndex, count)
return count