Skip to content
This repository was archived by the owner on Jan 20, 2023. It is now read-only.

Commit 421522b

Browse files
committed
初期化周りを効率化
1 parent 70354b0 commit 421522b

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

src/main/kotlin/com/mapk/core/KFunctionForCall.kt

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -88,16 +88,19 @@ class KFunctionForCall<T> internal constructor(
8888

8989
@Suppress("UNCHECKED_CAST")
9090
internal fun <T : Any> KClass<T>.toKConstructor(parameterNameConverter: ParameterNameConverter): KFunctionForCall<T> {
91-
val factoryConstructor: List<KFunctionForCall<T>> =
92-
this.companionObjectInstance?.let { companionObject ->
93-
companionObject::class.functions
94-
.filter { it.annotations.any { annotation -> annotation is KConstructor } }
95-
.map { KFunctionForCall(it, parameterNameConverter, companionObject) as KFunctionForCall<T> }
96-
} ?: emptyList()
97-
98-
val constructors: List<KFunctionForCall<T>> = factoryConstructor + this.constructors
91+
val constructors = ArrayList<KFunctionForCall<T>>()
92+
93+
this.companionObjectInstance?.let { companionObject ->
94+
companionObject::class.functions
95+
.filter { it.annotations.any { annotation -> annotation is KConstructor } }
96+
.forEach {
97+
constructors.add(KFunctionForCall(it, parameterNameConverter, companionObject) as KFunctionForCall<T>)
98+
}
99+
}
100+
101+
this.constructors
99102
.filter { it.annotations.any { annotation -> annotation is KConstructor } }
100-
.map { KFunctionForCall(it, parameterNameConverter) }
103+
.forEach { constructors.add(KFunctionForCall(it, parameterNameConverter)) }
101104

102105
if (constructors.size == 1) return constructors.single()
103106

0 commit comments

Comments
 (0)