mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-24 06:50:08 +08:00
Enhance performance
This commit is contained in:
parent
0981122401
commit
0662dc839f
@ -129,16 +129,15 @@ internal object EventListenerManger {
|
||||
private val registriesMutex = Mutex()
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
internal suspend fun <E : Subscribable> get(clazz: KClass<out E>): EventListeners<E> = registriesMutex.withLock {
|
||||
if (registries.containsKey(clazz)) {
|
||||
return registries[clazz] as EventListeners<E>
|
||||
} else {
|
||||
internal suspend fun <E : Subscribable> get(clazz: KClass<out E>): EventListeners<E> =
|
||||
if (registries.containsKey(clazz)) registries[clazz] as EventListeners<E>
|
||||
else registriesMutex.withLock {
|
||||
EventListeners<E>().let {
|
||||
registries[clazz] = it
|
||||
return it
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
internal suspend fun <E : Subscribable> E.broadcastInternal(): E {
|
||||
|
Loading…
Reference in New Issue
Block a user