Minor. Use ArrayList instead of LinkedHashSet
Looks like there's no duplicates anyway
This commit is contained in:
@@ -84,6 +84,13 @@ fun <T> Collection<T>.toReadOnlyList(): List<T> =
|
||||
else -> ArrayList(this)
|
||||
}
|
||||
|
||||
fun <T> ArrayList<T>.compactIfPossible(): List<T> =
|
||||
when (size) {
|
||||
0 -> emptyList()
|
||||
1 -> listOf(first())
|
||||
else -> apply(ArrayList<T>::trimToSize)
|
||||
}
|
||||
|
||||
fun <T: Any> T?.singletonOrEmptyList(): List<T> =
|
||||
if (this != null) listOf(this) else emptyList()
|
||||
|
||||
@@ -92,4 +99,4 @@ fun <T> List<T>.indexOfFirst(startFrom: Int, predicate: (T) -> Boolean): Int {
|
||||
if (predicate(this[index])) return index
|
||||
}
|
||||
return -1
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user