File tree Expand file tree Collapse file tree 4 files changed +12
-4
lines changed
jsAndWasmShared/src/internal Expand file tree Collapse file tree 4 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -53,15 +53,15 @@ private val updateState =
5353 return state
5454 }
5555
56+ internal expect fun isZeroCount (countOrElement : Any? ): Boolean
57+
5658// countOrElement is pre-cached in dispatched continuation
5759// returns NO_THREAD_ELEMENTS if the contest does not have any ThreadContextElements
5860internal fun updateThreadContext (context : CoroutineContext , countOrElement : Any? ): Any? {
5961 @Suppress(" NAME_SHADOWING" )
6062 val countOrElement = countOrElement ? : threadContextElements(context)
61- @Suppress(" IMPLICIT_BOXING_IN_IDENTITY_EQUALS" )
6263 return when {
63- countOrElement == = 0 -> NO_THREAD_ELEMENTS // very fast path when there are no active ThreadContextElements
64- // ^^^ identity comparison for speed, we know zero always has the same identity
64+ isZeroCount(countOrElement) -> NO_THREAD_ELEMENTS // very fast path when there are no active ThreadContextElements
6565 countOrElement is Int -> {
6666 // slow path for multiple active ThreadContextElements, allocates ThreadState for multiple old values
6767 context.fold(ThreadState (context, countOrElement), updateState)
Original file line number Diff line number Diff line change 1+ package kotlinx.coroutines.internal
2+
3+ internal actual fun isZeroCount (countOrElement : Any? ): Boolean = countOrElement is Int && countOrElement == 0
Original file line number Diff line number Diff line change @@ -3,7 +3,9 @@ package kotlinx.coroutines.internal
33import kotlinx.coroutines.*
44import kotlin.coroutines.*
55
6-
6+ // identity comparison for speed, we know zero always has the same identity
7+ @Suppress(" IMPLICIT_BOXING_IN_IDENTITY_EQUALS" , " KotlinConstantConditions" )
8+ internal actual fun isZeroCount (countOrElement : Any? ): Boolean = countOrElement == = 0
79
810// top-level data class for a nicer out-of-the-box toString representation and class name
911@PublishedApi
Original file line number Diff line number Diff line change 1+ package kotlinx.coroutines.internal
2+
3+ internal actual fun isZeroCount (countOrElement : Any? ): Boolean = countOrElement is Int && countOrElement == 0
You can’t perform that action at this time.
0 commit comments