Commit c30be20e authored by topjohnwu's avatar topjohnwu

Minor CachedValue fix

parent 25c64db0
...@@ -8,9 +8,7 @@ class CachedValue<T>(private val factory: () -> T) : Lazy<T> { ...@@ -8,9 +8,7 @@ class CachedValue<T>(private val factory: () -> T) : Lazy<T> {
get() { get() {
val local = _val val local = _val
return local ?: synchronized(this) { return local ?: synchronized(this) {
val newInstance = factory() _val ?: factory().also { _val = it }
_val = newInstance
newInstance
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment