Skip to content

Commit 64ef375

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

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

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

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

33
import kotlinx.coroutines.*
4+
import kotlinx.coroutines.flow.internal.*
5+
import kotlinx.coroutines.flow.internal.unsafeFlow
46
import kotlinx.coroutines.internal.IgnoreJreRequirement
57
import kotlin.time.*
68

@@ -146,7 +148,7 @@ private class StartedEagerly : SharingStarted {
146148
}
147149

148150
private class StartedLazily : SharingStarted {
149-
override fun command(subscriptionCount: StateFlow<Int>): Flow<SharingCommand> = flow {
151+
override fun command(subscriptionCount: StateFlow<Int>): Flow<SharingCommand> = unsafeFlow {
150152
var started = false
151153
subscriptionCount.collect { count ->
152154
if (count > 0 && !started) {

0 commit comments

Comments
 (0)