W3cubDocs

/Kotlin

ensureCapacity

Platform and version requirements: JS (1.4), Native (1.3)
fun ensureCapacity(minimumCapacity: Int)
For Common, Native

Ensures that the capacity of this string builder is at least equal to the specified minimumCapacity.

If the current capacity is less than the minimumCapacity, a new backing storage is allocated with greater capacity. Otherwise, this method takes no action and simply returns.

For JS

Ensures that the capacity of this string builder is at least equal to the specified minimumCapacity.

If the current capacity is less than the minimumCapacity, a new backing storage is allocated with greater capacity. Otherwise, this method takes no action and simply returns.

In Kotlin/JS implementation of StringBuilder the size of the backing storage is not extended to comply the given minimumCapacity, thus calling this method has no effect on the further performance of operations.

© 2010–2020 JetBrains s.r.o. and Kotlin Programming Language contributors
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.text/-string-builder/ensure-capacity.html