A couple performance tweaks for animated images #trivial (#634)

* A couple performance tweaks for animated images

* @nguyenhuy's comments

* Avoid calling animatedImageData twice. Thanks @maicki.

* Fix call to background deallocation

* Good catch by @Adlai-Holler
This commit is contained in:
Garrett Moon
2017-12-04 14:56:04 -08:00
committed by GitHub
parent c1f517a7eb
commit 0b6d41f872
2 changed files with 64 additions and 46 deletions

View File

@@ -55,6 +55,7 @@ NSString *const ASAnimatedImageDefaultRunLoopMode = NSRunLoopCommonModes;
}
id <ASAnimatedImageProtocol> previousAnimatedImage = _animatedImage;
_animatedImage = animatedImage;
if (animatedImage != nil) {
@@ -80,6 +81,11 @@ NSString *const ASAnimatedImageDefaultRunLoopMode = NSRunLoopCommonModes;
}
[self animatedImageSet:_animatedImage previousAnimatedImage:previousAnimatedImage];
// Animated image can take while to dealloc, do it off the main queue
if (previousAnimatedImage != nil) {
ASPerformBackgroundDeallocation(&previousAnimatedImage);
}
}
- (void)animatedImageSet:(id <ASAnimatedImageProtocol>)newAnimatedImage previousAnimatedImage:(id <ASAnimatedImageProtocol>)previousAnimatedImage