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

This commit is contained in:
Bogdan Poplauschi 2016-06-01 09:45:13 +03:00
parent 9ea1602157
commit ada86ab939
1 changed files with 6 additions and 1 deletions

View File

@ -10,6 +10,7 @@
#import "SDWebImageDecoder.h" #import "SDWebImageDecoder.h"
#import "UIImage+MultiFormat.h" #import "UIImage+MultiFormat.h"
#import <CommonCrypto/CommonDigest.h> #import <CommonCrypto/CommonDigest.h>
#import "UIImage+GIF.h"
// See https://github.com/rs/SDWebImage/pull/1141 for discussion // See https://github.com/rs/SDWebImage/pull/1141 for discussion
@interface AutoPurgeCache : NSCache @interface AutoPurgeCache : NSCache
@ -398,7 +399,11 @@ FOUNDATION_STATIC_INLINE NSUInteger SDCacheCostForImage(UIImage *image) {
// First check the in-memory cache... // First check the in-memory cache...
UIImage *image = [self imageFromMemoryCacheForKey:key]; UIImage *image = [self imageFromMemoryCacheForKey:key];
if (image) { if (image) {
doneBlock(image, nil, SDImageCacheTypeMemory); NSData *diskData = nil;
if ([image isGIF]) {
diskData = [self diskImageDataBySearchingAllPathsForKey:key];
}
doneBlock(image, diskData, SDImageCacheTypeMemory);
return nil; return nil;
} }