Skip to content

Commit d5bdf6f

Browse files
committed
Improve performance of SharingStarted.StartedLazily by changing flow to unsafeFlow
1 parent 96de301 commit d5bdf6f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Diff for: kotlinx-coroutines-core/common/src/flow/SharingStarted.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package kotlinx.coroutines.flow
22

33
import kotlinx.coroutines.*
4+
import kotlinx.coroutines.flow.internal.unsafeFlow
45
import kotlinx.coroutines.internal.IgnoreJreRequirement
56
import kotlin.time.*
67

@@ -146,7 +147,7 @@ private class StartedEagerly : SharingStarted {
146147
}
147148

148149
private class StartedLazily : SharingStarted {
149-
override fun command(subscriptionCount: StateFlow<Int>): Flow<SharingCommand> = flow {
150+
override fun command(subscriptionCount: StateFlow<Int>): Flow<SharingCommand> = unsafeFlow {
150151
var started = false
151152
subscriptionCount.collect { count ->
152153
if (count > 0 && !started) {

0 commit comments

Comments
 (0)