From 42caecf27ba8e999e1b3f15da27cf46e732ae9af Mon Sep 17 00:00:00 2001 From: DreamPiggy Date: Mon, 6 Aug 2018 11:18:00 +0800 Subject: [PATCH] Fix that `shouldUseWeakMemoryCache` code was lost during merge conflict --- SDWebImage/SDMemoryCache.m | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/SDWebImage/SDMemoryCache.m b/SDWebImage/SDMemoryCache.m index e434f4ec..45759650 100644 --- a/SDWebImage/SDMemoryCache.m +++ b/SDWebImage/SDMemoryCache.m @@ -84,6 +84,9 @@ static void * SDMemoryCacheContext = &SDMemoryCacheContext; // `setObject:forKey:` just call this with 0 cost. Override this is enough - (void)setObject:(id)obj forKey:(id)key cost:(NSUInteger)g { [super setObject:obj forKey:key cost:g]; + if (!self.config.shouldUseWeakMemoryCache) { + return; + } if (key && obj) { // Store weak cache LOCK(self.weakCacheLock); @@ -94,6 +97,9 @@ static void * SDMemoryCacheContext = &SDMemoryCacheContext; - (id)objectForKey:(id)key { id obj = [super objectForKey:key]; + if (!self.config.shouldUseWeakMemoryCache) { + return obj; + } if (key && !obj) { // Check weak cache LOCK(self.weakCacheLock); @@ -113,6 +119,9 @@ static void * SDMemoryCacheContext = &SDMemoryCacheContext; - (void)removeObjectForKey:(id)key { [super removeObjectForKey:key]; + if (!self.config.shouldUseWeakMemoryCache) { + return; + } if (key) { // Remove weak cache LOCK(self.weakCacheLock); @@ -123,6 +132,9 @@ static void * SDMemoryCacheContext = &SDMemoryCacheContext; - (void)removeAllObjects { [super removeAllObjects]; + if (!self.config.shouldUseWeakMemoryCache) { + return; + } // Manually remove should also remove weak cache LOCK(self.weakCacheLock); [self.weakCache removeAllObjects];