Minor CachedValue fix

This commit is contained in:
topjohnwu 2019-10-24 04:02:01 -04:00
parent 25c64db0a1
commit c30be20e49

View File

@ -8,9 +8,7 @@ class CachedValue<T>(private val factory: () -> T) : Lazy<T> {
get() {
val local = _val
return local ?: synchronized(this) {
val newInstance = factory()
_val = newInstance
newInstance
_val ?: factory().also { _val = it }
}
}