From beab7b65198d7528c409b749836bf9d45b9df6fb Mon Sep 17 00:00:00 2001 From: Benzi Date: Tue, 28 Jan 2020 22:38:34 +0530 Subject: [PATCH] Fix LRUAnimationCache to evict cached items This bug fix ensures that items stored in `cacheMap` are also removed when an entry from `lruList` is removed. --- .../src/Public/AnimationCache/LRUAnimationCache.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lottie-swift/src/Public/AnimationCache/LRUAnimationCache.swift b/lottie-swift/src/Public/AnimationCache/LRUAnimationCache.swift index e63867d987..11f729f869 100644 --- a/lottie-swift/src/Public/AnimationCache/LRUAnimationCache.swift +++ b/lottie-swift/src/Public/AnimationCache/LRUAnimationCache.swift @@ -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 + } } }