Memory optimization. Do not put sets into caches

This commit is contained in:
Andrey Breslav
2014-11-05 08:30:32 +02:00
parent 7e1546d3e7
commit 1b8c7aaf3d
3 changed files with 22 additions and 24 deletions
@@ -21,6 +21,7 @@ import java.util.ArrayList
import java.util.HashMap
import java.util.HashSet
import java.util.Collections
import java.util.LinkedHashSet
public fun <K, V> Stream<V>.valuesToMap(key: (V) -> K): Map<K, V> {
val map = LinkedHashMap<K, V>()
@@ -97,7 +98,4 @@ public fun <E> newHashSetWithExpectedSize(expectedSize: Int): HashSet<E> {
}
public fun <T> Collection<T>.toReadOnlyList(): List<T> =
if (isEmpty()) Collections.emptyList() else ArrayList(this)
public fun <T> Collection<T>.toReadOnlySet(): Set<T> =
if (isEmpty()) Collections.emptySet() else HashSet(this)
if (isEmpty()) Collections.emptyList() else ArrayList(this)