Small performance optimization of MutableMap.applyDiff

This commit is contained in:
2025-04-11 22:39:18 +06:00
parent 39415550f5
commit 5f93706d91
2 changed files with 5 additions and 4 deletions

View File

@@ -2,6 +2,9 @@
## 0.25.5
* `Common`:
* Small performance optimization of `MutableMap.applyDiff`
## 0.25.4
* `Versions`:

View File

@@ -82,13 +82,11 @@ fun <K, V> MutableMap<K, V>.applyDiff(
mapDiff: MapDiff<K, V>
) {
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)
}
}