Fix Snode Version CACHE usage

This commit is contained in:
bemusementpark 2024-08-05 09:59:02 +09:30
parent 61cb602e63
commit fa0abef243

View File

@ -42,10 +42,7 @@ class Snode(val address: String, val port: Int, val publicKeySet: KeySet?, val v
private val CACHE = mutableMapOf<String, Version>()
@SuppressLint("NotConstructor")
fun Version(value: String) = CACHE.getOrElse(value) {
// internal constructor takes precedence
Snode.Version(value)
}
fun Version(value: String) = CACHE[value] ?: Snode.Version(value).also { CACHE[value] = it }
fun Version(parts: List<Int>) = Version(parts.joinToString("."))
}