Remove lock tradeoff when get fetchFrame

This commit is contained in:
zhongwuzw 2018-08-31 21:53:53 +08:00
parent 6d85cd9061
commit 759b7322c9
1 changed files with 2 additions and 5 deletions

View File

@ -689,8 +689,10 @@ static NSUInteger SDDeviceFreeMemory() {
// Update the current frame
UIImage *currentFrame;
UIImage *fetchFrame;
LOCKBLOCK({
currentFrame = self.frameBuffer[@(currentFrameIndex)];
fetchFrame = currentFrame ? self.frameBuffer[@(nextFrameIndex)] : nil;
});
BOOL bufferFull = NO;
if (currentFrame) {
@ -744,11 +746,6 @@ static NSUInteger SDDeviceFreeMemory() {
fetchFrameIndex = nextFrameIndex;
}
UIImage *fetchFrame;
LOCKBLOCK({
fetchFrame = self.frameBuffer[@(fetchFrameIndex)];
});
if (!fetchFrame && !bufferFull && self.fetchQueue.operationCount == 0) {
// Prefetch next frame in background queue
UIImage<SDAnimatedImage> *animatedImage = self.animatedImage;