Skip to content

Commit ef6737d

Browse files
authored
Merge pull request #685 from k163377/fix/options
Streamline default value management for KotlinFeatures.
2 parents fdc519b + e61b48a commit ef6737d

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

release-notes/CREDITS-2.x

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Contributors:
1818
# 2.16.0 (not yet released)
1919

2020
WrongWrong (@k163377)
21+
* #685: Streamline default value management for KotlinFeatures
2122
* #684: Update Kotlin Version to 1.6
2223
* #682: Remove MissingKotlinParameterException and replace with MismatchedInputException
2324

release-notes/VERSION-2.x

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ Co-maintainers:
1818

1919
2.16.0 (not yet released)
2020

21+
#685: Streamline default value management for KotlinFeatures.
22+
This improves the initialization cost of kotlin-module a little.
2123
#684: Kotlin 1.5 has been deprecated and the minimum supported Kotlin version will be updated to 1.6.
2224
#682: Remove MissingKotlinParameterException and replace with MismatchedInputException
2325
This change removes MissingKotlinParameterException and resolves #617.

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ enum class KotlinFeature(private val enabledByDefault: Boolean) {
4444
*/
4545
StrictNullChecks(enabledByDefault = false);
4646

47-
internal val bitSet: BitSet = 2.0.pow(ordinal).toInt().toBitSet()
47+
internal val bitSet: BitSet = (1 shl ordinal).toBitSet()
4848

4949
companion object {
5050
internal val defaults
51-
get() = 0.toBitSet().apply {
52-
values().filter { it.enabledByDefault }.forEach { or(it.bitSet) }
51+
get() = values().fold(BitSet(Int.SIZE_BITS)) { acc, cur ->
52+
acc.apply { if (cur.enabledByDefault) this.or(cur.bitSet) }
5353
}
5454
}
5555
}

0 commit comments

Comments
 (0)