Undo unnecessary changes to stdlib
Partially revert "[stdlib] Reduce usage of extension functions"
This commit is contained in:
@@ -99,7 +99,7 @@ private val fullRuntimeSources = listOfKtFilesFrom(
|
|||||||
|
|
||||||
// Full version is defined in stdlib
|
// Full version is defined in stdlib
|
||||||
// This file is useful for smaller subset of runtime sources
|
// This file is useful for smaller subset of runtime sources
|
||||||
"libraries/stdlib/js/irRuntime/rangeExtensions.kt",
|
"libraries/stdlib/js/irRuntime/smallRuntimeMissingDeclarations.kt",
|
||||||
|
|
||||||
// Mostly array-specific stuff
|
// Mostly array-specific stuff
|
||||||
"libraries/stdlib/js/src/kotlin/builtins.kt",
|
"libraries/stdlib/js/src/kotlin/builtins.kt",
|
||||||
@@ -158,6 +158,8 @@ val reducedRuntimeSources = fullRuntimeSources - listOfKtFilesFrom(
|
|||||||
"libraries/stdlib/src/kotlin/util/KotlinVersion.kt",
|
"libraries/stdlib/src/kotlin/util/KotlinVersion.kt",
|
||||||
"libraries/stdlib/src/kotlin/util/Tuples.kt",
|
"libraries/stdlib/src/kotlin/util/Tuples.kt",
|
||||||
"libraries/stdlib/common/src/generated/_Comparisons.kt"
|
"libraries/stdlib/common/src/generated/_Comparisons.kt"
|
||||||
|
) + listOfKtFilesFrom(
|
||||||
|
"libraries/stdlib/js/irRuntime/smallRuntimeMissingDeclarations.kt"
|
||||||
)
|
)
|
||||||
|
|
||||||
private fun listOfKtFilesFrom(vararg paths: String): List<String> {
|
private fun listOfKtFilesFrom(vararg paths: String): List<String> {
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||||
|
* that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package kotlin
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns `true` if this char sequence is empty (contains no characters).
|
||||||
|
*/
|
||||||
|
@kotlin.internal.InlineOnly
|
||||||
|
public inline fun CharSequence.isEmpty(): Boolean = length == 0
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Accumulates value starting with [initial] value and applying [operation] from left to right to current accumulator value and each element.
|
||||||
|
*/
|
||||||
|
public inline fun <T, R> Array<out T>.fold(initial: R, operation: (acc: R, T) -> R): R {
|
||||||
|
var accumulator = initial
|
||||||
|
for (element in this) accumulator = operation(accumulator, element)
|
||||||
|
return accumulator
|
||||||
|
}
|
||||||
@@ -98,7 +98,7 @@ internal class CombinedContext(
|
|||||||
|
|
||||||
override fun toString(): String =
|
override fun toString(): String =
|
||||||
"[" + fold("") { acc, element ->
|
"[" + fold("") { acc, element ->
|
||||||
if (acc.length == 0) element.toString() else "$acc, $element"
|
if (acc.isEmpty()) element.toString() else "$acc, $element"
|
||||||
} + "]"
|
} + "]"
|
||||||
|
|
||||||
private fun writeReplace(): Any {
|
private fun writeReplace(): Any {
|
||||||
@@ -116,11 +116,6 @@ internal class CombinedContext(
|
|||||||
private const val serialVersionUID: Long = 0L
|
private const val serialVersionUID: Long = 0L
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun readResolve(): Any {
|
private fun readResolve(): Any = elements.fold(EmptyCoroutineContext, CoroutineContext::plus)
|
||||||
var result: CoroutineContext = EmptyCoroutineContext
|
|
||||||
for (element in elements)
|
|
||||||
result = result + element
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ public inline fun <T> T.takeUnless(predicate: (T) -> Boolean): T? {
|
|||||||
public inline fun repeat(times: Int, action: (Int) -> Unit) {
|
public inline fun repeat(times: Int, action: (Int) -> Unit) {
|
||||||
contract { callsInPlace(action) }
|
contract { callsInPlace(action) }
|
||||||
|
|
||||||
for (index in 0 .. (times - 1)) {
|
for (index in 0 until times) {
|
||||||
action(index)
|
action(index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user