Make consistent parameter nullability with appendLine
(cherry picked from commit f4bddc0552dd2bd0bf59c6b305112488f90b69d7)
This commit is contained in:
committed by
Vasily Levchenko
parent
bb397b6991
commit
ebc2dc64b2
@@ -178,10 +178,13 @@ actual class StringBuilder private constructor (
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Appends the specified string [value] to this string builder and returns this instance.
|
* Appends the specified string [value] to this string builder and returns this instance.
|
||||||
|
*
|
||||||
|
* If [value] is `null`, then the four characters `"null"` are appended.
|
||||||
*/
|
*/
|
||||||
actual fun append(value: String): StringBuilder {
|
actual fun append(value: String?): StringBuilder {
|
||||||
ensureExtraCapacity(value.length)
|
val toAppend = value ?: "null"
|
||||||
_length += insertString(array, _length, value)
|
ensureExtraCapacity(toAppend.length)
|
||||||
|
_length += insertString(array, _length, toAppend)
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -338,13 +341,16 @@ actual class StringBuilder private constructor (
|
|||||||
/**
|
/**
|
||||||
* Inserts the string [value] into this string builder at the specified [index] and returns this instance.
|
* Inserts the string [value] into this string builder at the specified [index] and returns this instance.
|
||||||
*
|
*
|
||||||
|
* If [value] is `null`, then the four characters `"null"` are inserted.
|
||||||
|
*
|
||||||
* @throws IndexOutOfBoundsException if [index] is less than zero or greater than the length of this string builder.
|
* @throws IndexOutOfBoundsException if [index] is less than zero or greater than the length of this string builder.
|
||||||
*/
|
*/
|
||||||
actual fun insert(index: Int, value: String): StringBuilder {
|
actual fun insert(index: Int, value: String?): StringBuilder {
|
||||||
|
val toInsert = value ?: "null"
|
||||||
checkInsertIndex(index)
|
checkInsertIndex(index)
|
||||||
ensureExtraCapacity(value.length)
|
ensureExtraCapacity(toInsert.length)
|
||||||
array.copyInto(array, startIndex = index, endIndex = _length, destinationOffset = index + value.length)
|
array.copyInto(array, startIndex = index, endIndex = _length, destinationOffset = index + toInsert.length)
|
||||||
_length += insertString(array, index, value)
|
_length += insertString(array, index, toInsert)
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user