W3cubDocs

/Kotlin

trimToSize

Platform and version requirements: JS (1.4), Native (1.3)
fun trimToSize()
For Common, Native

Attempts to reduce storage used for this string builder.

If the backing storage of this string builder is larger than necessary to hold its current contents, then it may be resized to become more space efficient. Calling this method may, but is not required to, affect the value of the capacity property.

For JS

Attempts to reduce storage used for this string builder.

If the backing storage of this string builder is larger than necessary to hold its current contents, then it may be resized to become more space efficient. Calling this method may, but is not required to, affect the value of the capacity property.

In Kotlin/JS implementation of StringBuilder the size of the backing storage is always equal to the length of the string builder.

© 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/trim-to-size.html