diff --git a/libraries/stdlib/src/generated/_Mapping.kt b/libraries/stdlib/src/generated/_Mapping.kt index a103a03e4cd..b6a8541d96a 100644 --- a/libraries/stdlib/src/generated/_Mapping.kt +++ b/libraries/stdlib/src/generated/_Mapping.kt @@ -521,77 +521,77 @@ public inline fun String.groupByTo(map: MutableMap>, to * Returns a list containing the results of applying the given *transform* function to each element of the original collection */ public inline fun Array.map(transform: (T) -> R): List { - return mapTo(ArrayList(), transform) + return mapTo(ArrayList(size()), transform) } /** * Returns a list containing the results of applying the given *transform* function to each element of the original collection */ public inline fun BooleanArray.map(transform: (Boolean) -> R): List { - return mapTo(ArrayList(), transform) + return mapTo(ArrayList(size()), transform) } /** * Returns a list containing the results of applying the given *transform* function to each element of the original collection */ public inline fun ByteArray.map(transform: (Byte) -> R): List { - return mapTo(ArrayList(), transform) + return mapTo(ArrayList(size()), transform) } /** * Returns a list containing the results of applying the given *transform* function to each element of the original collection */ public inline fun CharArray.map(transform: (Char) -> R): List { - return mapTo(ArrayList(), transform) + return mapTo(ArrayList(size()), transform) } /** * Returns a list containing the results of applying the given *transform* function to each element of the original collection */ public inline fun DoubleArray.map(transform: (Double) -> R): List { - return mapTo(ArrayList(), transform) + return mapTo(ArrayList(size()), transform) } /** * Returns a list containing the results of applying the given *transform* function to each element of the original collection */ public inline fun FloatArray.map(transform: (Float) -> R): List { - return mapTo(ArrayList(), transform) + return mapTo(ArrayList(size()), transform) } /** * Returns a list containing the results of applying the given *transform* function to each element of the original collection */ public inline fun IntArray.map(transform: (Int) -> R): List { - return mapTo(ArrayList(), transform) + return mapTo(ArrayList(size()), transform) } /** * Returns a list containing the results of applying the given *transform* function to each element of the original collection */ public inline fun LongArray.map(transform: (Long) -> R): List { - return mapTo(ArrayList(), transform) + return mapTo(ArrayList(size()), transform) } /** * Returns a list containing the results of applying the given *transform* function to each element of the original collection */ public inline fun ShortArray.map(transform: (Short) -> R): List { - return mapTo(ArrayList(), transform) + return mapTo(ArrayList(size()), transform) } /** * Returns a list containing the results of applying the given *transform* function to each element of the original collection */ public inline fun Iterable.map(transform: (T) -> R): List { - return mapTo(ArrayList(), transform) + return mapTo(ArrayList(collectionSizeOrDefault(10)), transform) } /** * Returns a list containing the results of applying the given *transform* function to each element of the original collection */ public inline fun Map.map(transform: (Map.Entry) -> R): List { - return mapTo(ArrayList(), transform) + return mapTo(ArrayList(size()), transform) } /** @@ -614,7 +614,7 @@ public fun Stream.map(transform: (T) -> R): Stream { * Returns a list containing the results of applying the given *transform* function to each element of the original collection */ public inline fun String.map(transform: (Char) -> R): List { - return mapTo(ArrayList(), transform) + return mapTo(ArrayList(length()), transform) } /** diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Mapping.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Mapping.kt index 77fbd088c5e..563679e2be3 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Mapping.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Mapping.kt @@ -74,7 +74,13 @@ fun mapping(): List { typeParam("R") returns("List") body { - "return mapTo(ArrayList(), transform)" + "return mapTo(ArrayList(collectionSizeOrDefault(10)), transform)" + } + body(ArraysOfObjects, ArraysOfPrimitives, Maps) { + "return mapTo(ArrayList(size()), transform)" + } + body(Strings) { + "return mapTo(ArrayList(length()), transform)" } inline(false, Sequences)