[NFC] A little optimization for MutableArray creation
This commit is contained in:
parent
347cf1d1cc
commit
9b2ddc9ea8
|
@ -173,7 +173,7 @@ static const CGFloat kDestSeemOverlap = 2.0f; // the numbers of pixels to over
|
|||
return nil;
|
||||
}
|
||||
|
||||
NSMutableArray<SDImageFrame *> *frames = [NSMutableArray array];
|
||||
NSMutableArray<SDImageFrame *> *frames;
|
||||
NSUInteger frameCount = 0;
|
||||
|
||||
#if SD_UIKIT || SD_WATCH
|
||||
|
@ -182,6 +182,7 @@ static const CGFloat kDestSeemOverlap = 2.0f; // the numbers of pixels to over
|
|||
if (frameCount == 0) {
|
||||
return nil;
|
||||
}
|
||||
frames = [NSMutableArray arrayWithCapacity:frameCount];
|
||||
|
||||
NSTimeInterval avgDuration = animatedImage.duration / frameCount;
|
||||
if (avgDuration == 0) {
|
||||
|
@ -223,6 +224,7 @@ static const CGFloat kDestSeemOverlap = 2.0f; // the numbers of pixels to over
|
|||
if (frameCount == 0) {
|
||||
return nil;
|
||||
}
|
||||
frames = [NSMutableArray arrayWithCapacity:frameCount];
|
||||
CGFloat scale = animatedImage.scale;
|
||||
|
||||
for (size_t i = 0; i < frameCount; i++) {
|
||||
|
|
|
@ -331,7 +331,7 @@ static NSString * kSDCGImageDestinationRequestedFileSize = @"kCGImageDestination
|
|||
if (decodeFirstFrame || count <= 1) {
|
||||
animatedImage = [self.class createFrameAtIndex:0 source:source scale:scale preserveAspectRatio:preserveAspectRatio thumbnailSize:thumbnailSize forceDecode:NO options:nil];
|
||||
} else {
|
||||
NSMutableArray<SDImageFrame *> *frames = [NSMutableArray array];
|
||||
NSMutableArray<SDImageFrame *> *frames = [NSMutableArray arrayWithCapacity:count];
|
||||
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
UIImage *image = [self.class createFrameAtIndex:i source:source scale:scale preserveAspectRatio:preserveAspectRatio thumbnailSize:thumbnailSize forceDecode:NO options:nil];
|
||||
|
|
|
@ -85,9 +85,10 @@ inline UIImage * _Nullable SDScaledImageForScaleFactor(CGFloat scale, UIImage *
|
|||
UIImage *animatedImage;
|
||||
#if SD_UIKIT || SD_WATCH
|
||||
// `UIAnimatedImage` images share the same size and scale.
|
||||
NSMutableArray<UIImage *> *scaledImages = [NSMutableArray array];
|
||||
NSArray<UIImage *> *images = image.images;
|
||||
NSMutableArray<UIImage *> *scaledImages = [NSMutableArray arrayWithCapacity:images.count];
|
||||
|
||||
for (UIImage *tempImage in image.images) {
|
||||
for (UIImage *tempImage in images) {
|
||||
UIImage *tempScaledImage = [[UIImage alloc] initWithCGImage:tempImage.CGImage scale:scale orientation:tempImage.imageOrientation];
|
||||
[scaledImages addObject:tempScaledImage];
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue