Skip to content

Commit 6ea4a18

Browse files
committed
perf: positionFlow decode
1 parent 2bf1eb8 commit 6ea4a18

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

app/src/main/kotlin/li/songe/gkd/service/OverlayWindowService.kt

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,12 @@ abstract class OverlayWindowService : LifecycleService(), SavedStateRegistryOwne
8383
createTextFlow(
8484
key = positionStoreKey,
8585
decode = {
86-
val list = (it ?: "").split(',', limit = 2).takeIf { l -> l.size == 2 }
87-
if (list != null) {
88-
val a = list.getOrNull(0)?.toIntOrNull() ?: 0
89-
val b = list.getOrNull(1)?.toIntOrNull() ?: 0
90-
a to b
91-
} else {
92-
0 to 0
86+
(it ?: "").split(',', limit = 2).mapNotNull { v -> v.toIntOrNull() }.run {
87+
if (size == 2) {
88+
get(0) to get(1)
89+
} else {
90+
0 to 0
91+
}
9392
}
9493
},
9594
encode = {

0 commit comments

Comments
 (0)