[FIR] Rename KEY and VALUE generics of FirCache to K and V
This commit is contained in:
+7
-7
@@ -8,14 +8,14 @@ package org.jetbrains.kotlin.idea.fir.low.level.api.fir.caches
|
||||
import org.jetbrains.kotlin.fir.caches.FirCache
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
internal class FirThreadSafeCache<KEY : Any, VALUE, CONTEXT>(
|
||||
private val createValue: (KEY, CONTEXT) -> VALUE
|
||||
) : FirCache<KEY, VALUE, CONTEXT>() {
|
||||
private val map = ConcurrentHashMap<KEY, Any>()
|
||||
internal class FirThreadSafeCache<K : Any, V, CONTEXT>(
|
||||
private val createValue: (K, CONTEXT) -> V
|
||||
) : FirCache<K, V, CONTEXT>() {
|
||||
private val map = ConcurrentHashMap<K, Any>()
|
||||
|
||||
override fun getValue(key: KEY, context: CONTEXT): VALUE =
|
||||
override fun getValue(key: K, context: CONTEXT): V =
|
||||
map.computeIfAbsentWithNullableValue(key) { createValue(it, context) }
|
||||
|
||||
override fun getValueIfComputed(key: KEY): VALUE? =
|
||||
override fun getValueIfComputed(key: K): V? =
|
||||
map[key]?.nullValueToNull()
|
||||
}
|
||||
}
|
||||
|
||||
+8
-8
@@ -8,14 +8,14 @@ package org.jetbrains.kotlin.idea.fir.low.level.api.fir.caches
|
||||
import org.jetbrains.kotlin.fir.caches.FirCache
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
internal class FirThreadSafeCacheWithPostCompute<KEY : Any, VALUE, CONTEXT, DATA>(
|
||||
private val createValue: (KEY, CONTEXT) -> Pair<VALUE, DATA>,
|
||||
private val postCompute: (KEY, VALUE, DATA) -> Unit
|
||||
) : FirCache<KEY, VALUE, CONTEXT>() {
|
||||
private val map = ConcurrentHashMap<KEY, ValueWithPostCompute<KEY, VALUE, DATA>>()
|
||||
internal class FirThreadSafeCacheWithPostCompute<K : Any, V, CONTEXT, DATA>(
|
||||
private val createValue: (K, CONTEXT) -> Pair<V, DATA>,
|
||||
private val postCompute: (K, V, DATA) -> Unit
|
||||
) : FirCache<K, V, CONTEXT>() {
|
||||
private val map = ConcurrentHashMap<K, ValueWithPostCompute<K, V, DATA>>()
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
override fun getValue(key: KEY, context: CONTEXT): VALUE =
|
||||
override fun getValue(key: K, context: CONTEXT): V =
|
||||
map.computeIfAbsent(key) {
|
||||
ValueWithPostCompute(
|
||||
key,
|
||||
@@ -24,6 +24,6 @@ internal class FirThreadSafeCacheWithPostCompute<KEY : Any, VALUE, CONTEXT, DATA
|
||||
)
|
||||
}.getValue()
|
||||
|
||||
override fun getValueIfComputed(key: KEY): VALUE? =
|
||||
override fun getValueIfComputed(key: K): V? =
|
||||
map[key]?.getValueIfComputed()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user