mirror of
https://github.com/LamGC/ScalaBot.git
synced 2025-04-29 22:27:31 +00:00
perf(config): 优化配置使用过程中的判断.
通过调整部分属性的 null-safety 特性, 移除了部分 non-null 判断, 略微(真的很略微)提高了性能(虽然仅限于启动).
This commit is contained in:
parent
b12758bd18
commit
a1790a0716
@ -140,7 +140,7 @@ internal class Launcher(private val config: AppConfig = Const.config) : AutoClos
|
||||
log.info { "正在启动机器人 `${botConfig.account.name}`..." }
|
||||
val botOption = DefaultBotOptions().apply {
|
||||
val proxyConfig =
|
||||
if (botConfig.proxy != null && botConfig.proxy!!.type != ProxyType.NO_PROXY) {
|
||||
if (botConfig.proxy.type != ProxyType.NO_PROXY) {
|
||||
botConfig.proxy
|
||||
} else if (config.proxy.type != ProxyType.NO_PROXY) {
|
||||
config.proxy
|
||||
@ -154,9 +154,7 @@ internal class Launcher(private val config: AppConfig = Const.config) : AutoClos
|
||||
log.debug { "机器人 `${botConfig.account.name}` 已启用代理配置: $proxyConfig" }
|
||||
}
|
||||
|
||||
if (botConfig.baseApiUrl != null) {
|
||||
baseUrl = botConfig.baseApiUrl
|
||||
}
|
||||
baseUrl = botConfig.baseApiUrl
|
||||
}
|
||||
val account = botConfig.account
|
||||
|
||||
|
@ -45,7 +45,7 @@ data class BotConfig(
|
||||
*/
|
||||
val extensions: Set<Artifact> = emptySet(),
|
||||
val proxy: ProxyConfig = ProxyConfig(type = ProxyType.NO_PROXY),
|
||||
val baseApiUrl: String? = ApiConstants.BASE_URL
|
||||
val baseApiUrl: String = ApiConstants.BASE_URL
|
||||
)
|
||||
|
||||
enum class ProxyType {
|
||||
|
Loading…
Reference in New Issue
Block a user