Skip to content

Commit 3c3d350

Browse files
committed
Reduce conversion cache from Executable to KFunction
1 parent 11787a4 commit 3c3d350

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/main/kotlin/com/fasterxml/jackson/module/kotlin/ReflectionCache.kt

+6-7
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import kotlin.reflect.jvm.kotlinFunction
1919
internal class ReflectionCache(reflectionCacheSize: Int) : Serializable {
2020
companion object {
2121
// Increment is required when properties that use LRUMap are changed.
22-
private const val serialVersionUID = 1L
22+
private const val serialVersionUID = 2L
2323
}
2424

2525
sealed class BooleanTriState(val value: Boolean?) {
@@ -42,8 +42,7 @@ internal class ReflectionCache(reflectionCacheSize: Int) : Serializable {
4242
}
4343
}
4444

45-
private val javaConstructorToKotlin = LRUMap<Constructor<*>, KFunction<*>>(reflectionCacheSize, reflectionCacheSize)
46-
private val javaMethodToKotlin = LRUMap<Method, KFunction<*>>(reflectionCacheSize, reflectionCacheSize)
45+
private val javaExecutableToKotlin = LRUMap<Executable, KFunction<*>>(reflectionCacheSize, reflectionCacheSize)
4746
private val javaExecutableToValueCreator = LRUMap<Executable, ValueCreator<*>>(reflectionCacheSize, reflectionCacheSize)
4847
private val javaConstructorIsCreatorAnnotated = LRUMap<AnnotatedConstructor, Boolean>(reflectionCacheSize, reflectionCacheSize)
4948
private val javaMemberIsRequired = LRUMap<AnnotatedMember, BooleanTriState?>(reflectionCacheSize, reflectionCacheSize)
@@ -57,11 +56,11 @@ internal class ReflectionCache(reflectionCacheSize: Int) : Serializable {
5756
private val valueClassBoxConverterCache: LRUMap<KClass<*>, ValueClassBoxConverter<*, *>> =
5857
LRUMap(0, reflectionCacheSize)
5958

60-
fun kotlinFromJava(key: Constructor<*>): KFunction<*>? = javaConstructorToKotlin.get(key)
61-
?: key.kotlinFunction?.let { javaConstructorToKotlin.putIfAbsent(key, it) ?: it }
59+
fun kotlinFromJava(key: Constructor<*>): KFunction<*>? = javaExecutableToKotlin.get(key)
60+
?: key.kotlinFunction?.let { javaExecutableToKotlin.putIfAbsent(key, it) ?: it }
6261

63-
fun kotlinFromJava(key: Method): KFunction<*>? = javaMethodToKotlin.get(key)
64-
?: key.kotlinFunction?.let { javaMethodToKotlin.putIfAbsent(key, it) ?: it }
62+
fun kotlinFromJava(key: Method): KFunction<*>? = javaExecutableToKotlin.get(key)
63+
?: key.kotlinFunction?.let { javaExecutableToKotlin.putIfAbsent(key, it) ?: it }
6564

6665
/**
6766
* return null if...

0 commit comments

Comments
 (0)