Use for instead of forEach with ranges (#1035)
* Use `for` instead of `forEach` with ranges. `forEach` is several times slower when used with ranges. * Add changelog
This commit is contained in:
committed by
GitHub
parent
8a0ad443d1
commit
c14cf15d4f
1
changelog.d/1035.bugfix
Normal file
1
changelog.d/1035.bugfix
Normal file
@@ -0,0 +1 @@
|
||||
Use `for` instead of `forEach` in `DefaultDiffCacheInvalidator` to improve performance.
|
||||
@@ -38,9 +38,9 @@ interface DiffCacheInvalidator<T> {
|
||||
class DefaultDiffCacheInvalidator<T> : DiffCacheInvalidator<T> {
|
||||
|
||||
override fun onChanged(position: Int, count: Int, cache: MutableDiffCache<T>) {
|
||||
(position until position + count).forEach {
|
||||
for (i in position until position + count) {
|
||||
// Invalidate cache
|
||||
cache[it] = null
|
||||
cache[i] = null
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user