mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
KTIJ-33008 [coroutines] Use StringBuilder instead of string concatenation to render CoroutineContext
Since there might be a lot of elements in the `CoroutineContext`, joining them with string concatenation in a cycle basically means O(N^2) performance GitOrigin-RevId: fe5652f0ff9b0abb43320fc7dd4d18f3118f2f38
This commit is contained in:
committed by
intellij-monorepo-bot
parent
19c34f9331
commit
3f6f508ccc
@@ -336,9 +336,12 @@ private fun traceToDump(info: DebugCoroutineInfo, stripTrace: Boolean): List<Sta
|
||||
}
|
||||
|
||||
private fun CoroutineContext.joinElementsToString(): String =
|
||||
this.fold("") { acc, element ->
|
||||
if (acc.isEmpty()) element.toString() else "$acc, $element"
|
||||
}
|
||||
this.fold(StringBuilder()) { acc, element ->
|
||||
if (acc.isNotEmpty()) {
|
||||
acc.append(", ")
|
||||
}
|
||||
acc.append(element.toString())
|
||||
}.toString()
|
||||
|
||||
private fun <T, R> MutableSet<T>.withElement(elem: T, body: (added: Boolean) -> R): R {
|
||||
val added = add(elem)
|
||||
|
||||
Reference in New Issue
Block a user