Skip to content

Commit

Permalink
Fix LRUAnimationCache to evict cached items
Browse files Browse the repository at this point in the history
This bug fix ensures that items stored in `cacheMap` are also removed when an entry from `lruList` is removed.
  • Loading branch information
BenziAhamed committed Jan 28, 2020
1 parent 8f81de8 commit beab7b6
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ public class LRUAnimationCache: AnimationCacheProvider {
cacheMap[forKey] = animation
lruList.append(forKey)
if lruList.count > cacheSize {
lruList.remove(at: 0)
let removed = lruList.remove(at: 0)
if removed != forKey {
cacheMap[removed] = nil
}
}
}

Expand Down

0 comments on commit beab7b6

Please sign in to comment.