File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
core/kt-fast-collections-generator/src/main/kotlin/collections Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -29,9 +29,16 @@ private fun CollectionItemType.generateArray(context: GeneratorContext, currentF
29
29
30
30
import ${type.qualifiedName}
31
31
32
+ // regular lambda types are compiled to a generic Function<In, Out> type, which boxes
33
+ // its arguments and return value. It's a significant performance bug.
34
+ fun interface ${simpleName} ArrayInitializer${paramsDecl} {
35
+ fun call(idx: Int): $type
36
+ }
37
+
32
38
@JvmInline
33
39
value class Mutable${simpleName} Array${paramsDecl} (private val data: $bufferType ) {
34
- public constructor(size: Int, init: (Int) -> $type ) : this($bufferType (size) { i -> ${storageType.toPrimitive(" init(i)" )} })
40
+ public constructor(size: Int, init: ${simpleName} ArrayInitializer${paramsUse} )
41
+ : this($bufferType (size) { i -> ${storageType.toPrimitive(" init.call(i)" )} })
35
42
36
43
val size get() = data.size
37
44
You can’t perform that action at this time.
0 commit comments