FIR IDE: use FirCaches in JavaSymbolProvider

This commit is contained in:
Ilya Kirillov
2021-01-17 04:32:22 +01:00
parent 1fef5859e3
commit 7284acc9f9
3 changed files with 44 additions and 50 deletions
@@ -29,23 +29,6 @@ inline class SymbolProviderCache<K, V : Any> @PrivateForInline constructor(@Priv
}
}
@OptIn(PrivateForInline::class)
inline fun <T> lookupCacheOrCalculateWithPostCompute(
key: K, crossinline l: (K) -> Pair<V?, T>, postCompute: (V, T) -> Unit
): V? {
@Suppress("UNCHECKED_CAST")
return when (val value = cache[key]) {
null -> {
val calculated = l(key)
cache[key] = calculated.first ?: NullValue
calculated.first?.let { postCompute(it, calculated.second) }
calculated.first
}
NullValue -> null
else -> value as V
}
}
@OptIn(PrivateForInline::class)
operator fun contains(key: K): Boolean = key in cache