diff --git a/changelog.d/1035.bugfix b/changelog.d/1035.bugfix new file mode 100644 index 0000000000..4a2a6376ce --- /dev/null +++ b/changelog.d/1035.bugfix @@ -0,0 +1 @@ +Use `for` instead of `forEach` in `DefaultDiffCacheInvalidator` to improve performance. diff --git a/libraries/androidutils/src/main/kotlin/io/element/android/libraries/androidutils/diff/DiffCacheInvalidator.kt b/libraries/androidutils/src/main/kotlin/io/element/android/libraries/androidutils/diff/DiffCacheInvalidator.kt index d9f378c8fa..4ebdc3224f 100644 --- a/libraries/androidutils/src/main/kotlin/io/element/android/libraries/androidutils/diff/DiffCacheInvalidator.kt +++ b/libraries/androidutils/src/main/kotlin/io/element/android/libraries/androidutils/diff/DiffCacheInvalidator.kt @@ -38,9 +38,9 @@ interface DiffCacheInvalidator { class DefaultDiffCacheInvalidator : DiffCacheInvalidator { override fun onChanged(position: Int, count: Int, cache: MutableDiffCache) { - (position until position + count).forEach { + for (i in position until position + count) { // Invalidate cache - cache[it] = null + cache[i] = null } }