Improve performance

This commit is contained in:
Him188 2020-06-24 03:48:11 +08:00
parent 9a91c9b2a7
commit 927943322a
2 changed files with 65 additions and 81 deletions

View File

@ -19,10 +19,6 @@ import net.mamoe.mirai.console.setting.internal.isOdd
import net.mamoe.mirai.console.setting.internal.valueFromKTypeImpl
import net.mamoe.mirai.console.setting.internal.valueImpl
import net.mamoe.mirai.utils.MiraiExperimentalAPI
import net.mamoe.yamlkt.Yaml
import net.mamoe.yamlkt.YamlConfiguration
import net.mamoe.yamlkt.YamlConfiguration.ListSerialization.FLOW_SEQUENCE
import net.mamoe.yamlkt.YamlConfiguration.MapSerialization.FLOW_MAP
import net.mamoe.yamlkt.YamlNullableDynamicSerializer
import kotlin.internal.LowPriorityInOverloadResolution
import kotlin.reflect.KProperty
@ -66,8 +62,7 @@ internal abstract class SettingImpl {
internal val valueNodes: MutableList<Node<*>> = mutableListOf()
internal open val updaterSerializer: KSerializer<Unit> by lazy {
object : KSerializer<Unit> {
internal open val updaterSerializer: KSerializer<Unit> = object : KSerializer<Unit> {
override val descriptor: SerialDescriptor get() = settingUpdaterSerializerDescriptor
@Suppress("UNCHECKED_CAST")
@ -135,7 +130,6 @@ internal abstract class SettingImpl {
}
}
}
/**
* flatten
@ -145,22 +139,9 @@ internal abstract class SettingImpl {
}
companion object {
private val ABSENT_STUB = Any()
private val settingUpdaterSerializerTypeArguments = arrayOf(String.serializer(), YamlNullableDynamicSerializer)
private val settingUpdaterSerializerDescriptor =
MapSerializer(settingUpdaterSerializerTypeArguments[0], settingUpdaterSerializerTypeArguments[1]).descriptor
val allFlow = Yaml(
YamlConfiguration(
nonStrictNullability = true,
nonStrictNumber = true,
mapSerialization = FLOW_MAP,
listSerialization = FLOW_SEQUENCE,
classSerialization = FLOW_MAP
)
)
}
}

View File

@ -0,0 +1,3 @@
package net.mamoe.mirai.console.setting
interface SettingStorage