Call compactIfPossible where it's possible in BinaryJava*

It helps to avoid retaining a lot of redundant empty SmartList's
instances
This commit is contained in:
Denis Zharkov
2017-05-25 16:39:16 +03:00
parent e2ce285ec3
commit d7cee95d95
3 changed files with 15 additions and 8 deletions
@@ -132,7 +132,7 @@ inline fun <T> measureTimeMillisWithResult(block: () -> T) : Pair<Long, T> {
return Pair(System.currentTimeMillis() - start, result)
}
public fun <T> Iterable<Iterable<T>>.flattenTo(c: MutableList<T>): List<T> {
fun <T, C : MutableCollection<in T>> Iterable<Iterable<T>>.flattenTo(c: C): C {
for (element in this) {
c.addAll(element)
}