-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf: async remap entries in jar (#82)
- Loading branch information
1 parent
6bcec62
commit 8a61eaa
Showing
4 changed files
with
133 additions
and
75 deletions.
There are no files selected for viewing
4 changes: 2 additions & 2 deletions
4
src/main/kotlin/xyz/bluspring/kilt/loader/KiltEarlierInitializer.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
package xyz.bluspring.kilt.loader | ||
|
||
import de.florianmichael.asmfabricloader.api.event.PrePrePreLaunchEntrypoint | ||
import kotlinx.coroutines.runBlocking | ||
|
||
class KiltEarlierInitializer : PrePrePreLaunchEntrypoint { | ||
override fun onLanguageAdapterLaunch() { | ||
KiltLoader.INSTANCE.scanModJob | ||
KiltLoader.INSTANCE.runScanMods() | ||
runBlocking { KiltLoader.INSTANCE.scanMods() } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package xyz.bluspring.kilt.util | ||
|
||
import kotlinx.coroutines.async | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.channelFlow | ||
import kotlinx.coroutines.flow.map | ||
import kotlinx.coroutines.flow.transform | ||
|
||
// https://github.com/Kotlin/kotlinx.coroutines/issues/1147 | ||
|
||
fun <T, R> Flow<T>.mapAsync(transform: suspend (value: T) -> R): Flow<R> = | ||
channelFlow { | ||
collect { e -> send(async { transform(e) }) } | ||
}.map { it.await() } | ||
|
||
fun <T> Flow<T>.filterAsync(predicate: suspend (value: T) -> Boolean): Flow<T> = | ||
mapAsync { it to predicate(it) }.transform { if (it.second) emit(it.first) } | ||
|
||
fun <T> Flow<T>.onEachAsync(action: suspend (value: T) -> Unit): Flow<T> = | ||
mapAsync { | ||
action(it) | ||
it | ||
} | ||
|
||
fun <T, R> Flow<T>.flatMapAsync(transform: suspend (value: T) -> Flow<R>): Flow<R> = | ||
mapAsync { transform(it) }.transform { it.collect { emit(it) } } |