diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ce523441e9..a86146be12e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## 0.25.5 +* `Common`: + * Small performance optimization of `MutableMap.applyDiff` + ## 0.25.4 * `Versions`: diff --git a/common/src/commonMain/kotlin/dev/inmo/micro_utils/common/MapDiff.kt b/common/src/commonMain/kotlin/dev/inmo/micro_utils/common/MapDiff.kt index dc275c347d1..c3d5bfed2e9 100644 --- a/common/src/commonMain/kotlin/dev/inmo/micro_utils/common/MapDiff.kt +++ b/common/src/commonMain/kotlin/dev/inmo/micro_utils/common/MapDiff.kt @@ -82,13 +82,11 @@ fun MutableMap.applyDiff( mapDiff: MapDiff ) { mapDiff.apply { - removed.keys.forEach { remove(it) } + keys.removeAll(removed.keys) changed.forEach { (k, oldNew) -> put(k, oldNew.second) } - added.forEach { (k, new) -> - put(k, new) - } + putAll(added) } }