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

Commit cf1b708

Browse files
committed
コンバータの取得処理は非常に重いため、使わない間は初期化しないよう修正
1 parent 125d976 commit cf1b708

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/main/kotlin/com/mapk/kmapper/ParameterForMap.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ internal class ParameterForMap<T : Any>(
2020
}
2121
// リストの長さが小さいと期待されるためこの形で実装しているが、理想的にはmap的なものが使いたい
2222
@Suppress("UNCHECKED_CAST")
23-
private val converters: Set<Pair<KClass<*>, KFunction<T>>> =
23+
private val converters: Set<Pair<KClass<*>, KFunction<T>>> by lazy {
2424
(param.getConverters() as Set<Pair<KClass<*>, KFunction<T>>>) + clazz.getConverters()
25+
}
2526

2627
private val convertCache: ConcurrentMap<KClass<*>, ParameterProcessor> = ConcurrentHashMap()
2728

src/main/kotlin/com/mapk/kmapper/PlainParameterForMap.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ internal class PlainParameterForMap<T : Any>(
1717
}
1818
// リストの長さが小さいと期待されるためこの形で実装しているが、理想的にはmap的なものが使いたい
1919
@Suppress("UNCHECKED_CAST")
20-
private val converters: Set<Pair<KClass<*>, KFunction<T>>> =
20+
private val converters: Set<Pair<KClass<*>, KFunction<T>>> by lazy {
2121
(param.getConverters() as Set<Pair<KClass<*>, KFunction<T>>>) + clazz.getConverters()
22+
}
2223

2324
fun <U : Any> mapObject(value: U): Any? {
2425
val valueClazz: KClass<*> = value::class

0 commit comments

Comments
 (0)