Do not create empty list when reversing empty collection or array — use singleton empty list instead.

#KT-8099 Fixed
This commit is contained in:
Ilya Gorbunov
2015-06-16 16:41:46 +03:00
parent 8a3182d1e7
commit a80f65cfd9
2 changed files with 30 additions and 0 deletions
@@ -10,6 +10,16 @@ fun ordering(): List<GenericFunction> {
returns { "List<T>" }
body {
"""
if (this is Collection<*> && isEmpty()) return emptyList()
val list = toArrayList()
Collections.reverse(list)
return list
"""
}
body(ArraysOfObjects, ArraysOfPrimitives) {
"""
if (isEmpty()) return emptyList()
val list = toArrayList()
Collections.reverse(list)
return list