mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-10 18:40:15 +08:00
Use lazy for SemVersion.toString
This commit is contained in:
parent
ef4d259f60
commit
7a533d4667
@ -188,23 +188,22 @@ public data class SemVersion internal constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Transient
|
@Transient
|
||||||
private var toString: String? = null // For cache.
|
private val toString: String by lazy(LazyThreadSafetyMode.NONE) {
|
||||||
override fun toString(): String {
|
buildString {
|
||||||
return toString ?: kotlin.run {
|
mainVersion.joinTo(this, ".")
|
||||||
buildString {
|
identifier?.let { identifier ->
|
||||||
mainVersion.joinTo(this, ".")
|
append('-')
|
||||||
identifier?.let { identifier ->
|
append(identifier)
|
||||||
append('-')
|
}
|
||||||
append(identifier)
|
metadata?.let { metadata ->
|
||||||
}
|
append('+')
|
||||||
metadata?.let { metadata ->
|
append(metadata)
|
||||||
append('+')
|
}
|
||||||
append(metadata)
|
|
||||||
}
|
|
||||||
}.also { toString = it }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun toString(): String = toString
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 将 [SemVersion] 转为 Kotlin data class 风格的 [String]
|
* 将 [SemVersion] 转为 Kotlin data class 风格的 [String]
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user