From ada86ab9396e678e66f71b395ca0c91ccd700790 Mon Sep 17 00:00:00 2001 From: Bogdan Poplauschi Date: Wed, 1 Jun 2016 09:45:13 +0300 Subject: [PATCH] Based on the previous change, we now can avoid the memory cache for GIFs, as the memory cache only holds UIImage instances and we need the NSData. Forced to load from disk if the image is a GIF --- SDWebImage/SDImageCache.m | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/SDWebImage/SDImageCache.m b/SDWebImage/SDImageCache.m index b8073cbc..f04b5af5 100644 --- a/SDWebImage/SDImageCache.m +++ b/SDWebImage/SDImageCache.m @@ -10,6 +10,7 @@ #import "SDWebImageDecoder.h" #import "UIImage+MultiFormat.h" #import +#import "UIImage+GIF.h" // See https://github.com/rs/SDWebImage/pull/1141 for discussion @interface AutoPurgeCache : NSCache @@ -398,7 +399,11 @@ FOUNDATION_STATIC_INLINE NSUInteger SDCacheCostForImage(UIImage *image) { // First check the in-memory cache... UIImage *image = [self imageFromMemoryCacheForKey:key]; if (image) { - doneBlock(image, nil, SDImageCacheTypeMemory); + NSData *diskData = nil; + if ([image isGIF]) { + diskData = [self diskImageDataBySearchingAllPathsForKey:key]; + } + doneBlock(image, diskData, SDImageCacheTypeMemory); return nil; }