map(): Take into account size of collection being transformed when allocating ArrayList.

#KT-7832 Fixed.
This commit is contained in:
Ilya Gorbunov
2015-05-25 20:52:31 +03:00
parent c9afb407f1
commit 45c82f2844
2 changed files with 19 additions and 13 deletions
@@ -74,7 +74,13 @@ fun mapping(): List<GenericFunction> {
typeParam("R")
returns("List<R>")
body {
"return mapTo(ArrayList<R>(), transform)"
"return mapTo(ArrayList<R>(collectionSizeOrDefault(10)), transform)"
}
body(ArraysOfObjects, ArraysOfPrimitives, Maps) {
"return mapTo(ArrayList<R>(size()), transform)"
}
body(Strings) {
"return mapTo(ArrayList<R>(length()), transform)"
}
inline(false, Sequences)