Performance: move the state out of multifile class parts to avoid synchronization.
This commit is contained in:
@@ -80,9 +80,6 @@ public fun <K, V> linkedMapOf(vararg pairs: Pair<K, V>): LinkedHashMap<K, V>
|
|||||||
* to the Collection constructor for HashSet, (c.size()/.75f) + 1, but provides further optimisations for very small or
|
* to the Collection constructor for HashSet, (c.size()/.75f) + 1, but provides further optimisations for very small or
|
||||||
* very large sizes, allows support non-collection classes, and provides consistency for all map based class construction.
|
* very large sizes, allows support non-collection classes, and provides consistency for all map based class construction.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private val INT_MAX_POWER_OF_TWO: Int = Int.MAX_VALUE / 2 + 1
|
|
||||||
|
|
||||||
@kotlin.internal.InlineExposed
|
@kotlin.internal.InlineExposed
|
||||||
internal fun mapCapacity(expectedSize: Int): Int {
|
internal fun mapCapacity(expectedSize: Int): Int {
|
||||||
if (expectedSize < 3) {
|
if (expectedSize < 3) {
|
||||||
@@ -94,6 +91,8 @@ internal fun mapCapacity(expectedSize: Int): Int {
|
|||||||
return Int.MAX_VALUE // any large value
|
return Int.MAX_VALUE // any large value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private const val INT_MAX_POWER_OF_TWO: Int = Int.MAX_VALUE / 2 + 1
|
||||||
|
|
||||||
/** Returns `true` if this map is not empty. */
|
/** Returns `true` if this map is not empty. */
|
||||||
@kotlin.internal.InlineOnly
|
@kotlin.internal.InlineOnly
|
||||||
public inline fun <K, V> Map<K, V>.isNotEmpty(): Boolean = !isEmpty()
|
public inline fun <K, V> Map<K, V>.isNotEmpty(): Boolean = !isEmpty()
|
||||||
|
|||||||
@@ -3,11 +3,14 @@
|
|||||||
|
|
||||||
package kotlin.text
|
package kotlin.text
|
||||||
|
|
||||||
/** Line separator for current system. */
|
private object SystemProperties {
|
||||||
private val LINE_SEPARATOR: String by lazy { System.getProperty("line.separator")!! }
|
/** Line separator for current system. */
|
||||||
|
@JvmField
|
||||||
|
val LINE_SEPARATOR = System.getProperty("line.separator")!!
|
||||||
|
}
|
||||||
|
|
||||||
/** Appends a line separator to this Appendable. */
|
/** Appends a line separator to this Appendable. */
|
||||||
public fun Appendable.appendln(): Appendable = append(LINE_SEPARATOR)
|
public fun Appendable.appendln(): Appendable = append(SystemProperties.LINE_SEPARATOR)
|
||||||
|
|
||||||
/** Appends value to the given Appendable and line separator after it. */
|
/** Appends value to the given Appendable and line separator after it. */
|
||||||
@kotlin.internal.InlineOnly
|
@kotlin.internal.InlineOnly
|
||||||
@@ -18,7 +21,7 @@ public inline fun Appendable.appendln(value: CharSequence?): Appendable = append
|
|||||||
public inline fun Appendable.appendln(value: Char): Appendable = append(value).appendln()
|
public inline fun Appendable.appendln(value: Char): Appendable = append(value).appendln()
|
||||||
|
|
||||||
/** Appends a line separator to this StringBuilder. */
|
/** Appends a line separator to this StringBuilder. */
|
||||||
public fun StringBuilder.appendln(): StringBuilder = append(LINE_SEPARATOR)
|
public fun StringBuilder.appendln(): StringBuilder = append(SystemProperties.LINE_SEPARATOR)
|
||||||
|
|
||||||
/** Appends [value] to this [StringBuilder], followed by a line separator. */
|
/** Appends [value] to this [StringBuilder], followed by a line separator. */
|
||||||
@kotlin.internal.InlineOnly
|
@kotlin.internal.InlineOnly
|
||||||
|
|||||||
Reference in New Issue
Block a user