@@ -358,11 +358,9 @@ - (NSUUID *)downloadImageWithURL:(NSURL *)url
358358 } else {
359359 taskClass = [PINRemoteImageDownloadTask class ];
360360 }
361-
362- BOOL earlyCheck = (PINRemoteImageManagerDownloadOptionsSkipEarlyCheck & options)?NO :YES ;
363- BOOL ignoreGIF = (PINRemoteImageManagerDownloadOptionsIgnoreGIFs & options)?YES :NO ;
361+
364362 if (url == nil ) {
365- [self earlyReturn: earlyCheck ignoreGIF: ignoreGIF url: nil object: nil queue: _callbackQueue completion: completion];
363+ [self earlyReturnWithOptions: options url: nil object: nil completion: completion];
366364 return nil ;
367365 }
368366
@@ -380,7 +378,7 @@ - (NSUUID *)downloadImageWithURL:(NSURL *)url
380378 // If so, special case this to avoid flashing the UI
381379 id object = [self .cache.memoryCache objectForKey: key];
382380 if (object) {
383- if ([self earlyReturn: earlyCheck ignoreGIF: ignoreGIF url: url object: object queue: _callbackQueue completion: completion]) {
381+ if ([self earlyReturnWithOptions: options url: url object: object completion: completion]) {
384382 return nil ;
385383 }
386384 }
@@ -608,32 +606,35 @@ - (void)downloadImageWithURL:(NSURL *)url
608606 [self unlock ];
609607}
610608
611- - (BOOL )earlyReturn : ( BOOL ) earlyReturn ignoreGIF : ( BOOL ) ignoreGIF url : (NSURL *)url object : (id )object queue : ( dispatch_queue_t ) callbackQueue completion : (PINRemoteImageManagerImageCompletion)completion
609+ - (BOOL )earlyReturnWithOptions : (PINRemoteImageManagerDownloadOptions) options url : (NSURL *)url object : (id )object completion : (PINRemoteImageManagerImageCompletion)completion
612610{
613611 UIImage *image = nil ;
614612 FLAnimatedImage *animatedImage = nil ;
615613 PINRemoteImageResultType resultType = PINRemoteImageResultTypeNone;
616-
614+
615+ BOOL allowEarlyReturn = !(PINRemoteImageManagerDownloadOptionsSkipEarlyCheck & options);
616+ BOOL allowAnimated = !(PINRemoteImageManagerDownloadOptionsIgnoreGIFs & options);
617+
617618 if (url != nil ) {
618619 resultType = PINRemoteImageResultTypeMemoryCache;
619620 if ([object isKindOfClass: [UIImage class ]]) {
620621 image = (UIImage *)object;
621- } else if (ignoreGIF == NO && [object isKindOfClass: [NSData class ]] && [(NSData *)object pin_isGIF ]) {
622+ } else if (allowAnimated && [object isKindOfClass: [NSData class ]] && [(NSData *)object pin_isGIF ]) {
622623 animatedImage = [FLAnimatedImage animatedImageWithGIFData: object];
623624 }
624625 }
625626
626627 if (completion && ((image || animatedImage) || (url == nil ))) {
627628 // If we're on the main thread, special case to call completion immediately
628- if (earlyReturn && [NSThread isMainThread ]) {
629+ if (allowEarlyReturn && [NSThread isMainThread ]) {
629630 completion ([PINRemoteImageManagerResult imageResultWithImage: image
630631 animatedImage: animatedImage
631632 requestLength: 0
632633 error: nil
633634 resultType: resultType
634635 UUID: nil ]);
635636 } else {
636- dispatch_async (_callbackQueue , ^{
637+ dispatch_async (self. callbackQueue , ^{
637638 completion ([PINRemoteImageManagerResult imageResultWithImage: image
638639 animatedImage: animatedImage
639640 requestLength: 0
0 commit comments