Undo unnecessary changes to stdlib

Partially revert "[stdlib] Reduce usage of extension functions"
This commit is contained in:
Svyatoslav Kuzmich
2019-01-29 15:04:44 +03:00
parent 0ef4194770
commit c9e2ed4e1f
4 changed files with 27 additions and 9 deletions
@@ -98,7 +98,7 @@ internal class CombinedContext(
override fun toString(): String =
"[" + fold("") { acc, element ->
if (acc.length == 0) element.toString() else "$acc, $element"
if (acc.isEmpty()) element.toString() else "$acc, $element"
} + "]"
private fun writeReplace(): Any {
@@ -116,11 +116,6 @@ internal class CombinedContext(
private const val serialVersionUID: Long = 0L
}
private fun readResolve(): Any {
var result: CoroutineContext = EmptyCoroutineContext
for (element in elements)
result = result + element
return result
}
private fun readResolve(): Any = elements.fold(EmptyCoroutineContext, CoroutineContext::plus)
}
}
+1 -1
View File
@@ -135,7 +135,7 @@ public inline fun <T> T.takeUnless(predicate: (T) -> Boolean): T? {
public inline fun repeat(times: Int, action: (Int) -> Unit) {
contract { callsInPlace(action) }
for (index in 0 .. (times - 1)) {
for (index in 0 until times) {
action(index)
}
}