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:
parent
ca63bebe5f
commit
598a63d267
2 changed files with 3 additions and 2 deletions
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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue