diff --git a/release-notes/CREDITS-2.x b/release-notes/CREDITS-2.x index c05e769b4..ff7a5c224 100644 --- a/release-notes/CREDITS-2.x +++ b/release-notes/CREDITS-2.x @@ -18,6 +18,7 @@ Contributors: # 2.16.0 (not yet released) WrongWrong (@k163377) +* #685: Streamline default value management for KotlinFeatures * #684: Update Kotlin Version to 1.6 * #682: Remove MissingKotlinParameterException and replace with MismatchedInputException diff --git a/release-notes/VERSION-2.x b/release-notes/VERSION-2.x index ed9728ef1..35297bb39 100644 --- a/release-notes/VERSION-2.x +++ b/release-notes/VERSION-2.x @@ -18,6 +18,8 @@ Co-maintainers: 2.16.0 (not yet released) +#685: Streamline default value management for KotlinFeatures. + This improves the initialization cost of kotlin-module a little. #684: Kotlin 1.5 has been deprecated and the minimum supported Kotlin version will be updated to 1.6. #682: Remove MissingKotlinParameterException and replace with MismatchedInputException This change removes MissingKotlinParameterException and resolves #617. diff --git a/src/main/kotlin/com/fasterxml/jackson/module/kotlin/KotlinFeature.kt b/src/main/kotlin/com/fasterxml/jackson/module/kotlin/KotlinFeature.kt index c8c54d25e..27af0f233 100644 --- a/src/main/kotlin/com/fasterxml/jackson/module/kotlin/KotlinFeature.kt +++ b/src/main/kotlin/com/fasterxml/jackson/module/kotlin/KotlinFeature.kt @@ -44,12 +44,12 @@ enum class KotlinFeature(private val enabledByDefault: Boolean) { */ StrictNullChecks(enabledByDefault = false); - internal val bitSet: BitSet = 2.0.pow(ordinal).toInt().toBitSet() + internal val bitSet: BitSet = (1 shl ordinal).toBitSet() companion object { internal val defaults - get() = 0.toBitSet().apply { - values().filter { it.enabledByDefault }.forEach { or(it.bitSet) } + get() = values().fold(BitSet(Int.SIZE_BITS)) { acc, cur -> + acc.apply { if (cur.enabledByDefault) this.or(cur.bitSet) } } } }