[FIR] Split ResolveUtils.kt from :resolve to separate files

This commit is contained in:
Dmitriy Novozhilov
2020-08-28 11:32:15 +03:00
parent 6ace4164ff
commit ca031f7ace
6 changed files with 186 additions and 145 deletions
@@ -177,3 +177,15 @@ inline fun <T, R> Collection<T>.foldMap(transform: (T) -> R, operation: (R, R) -
fun <E> MutableList<E>.trimToSize(newSize: Int) {
subList(newSize, size).clear()
}
inline fun <K, V, VA : V> MutableMap<K, V>.getOrPut(key: K, defaultValue: (K) -> VA, postCompute: (VA) -> Unit): V {
val value = get(key)
return if (value == null) {
val answer = defaultValue(key)
put(key, answer)
postCompute(answer)
answer
} else {
value
}
}