From 042c27ec8c62ec09cea2ee2f5042790c5df6258d Mon Sep 17 00:00:00 2001 From: Noah Date: Tue, 30 Oct 2018 01:26:44 +0800 Subject: [PATCH 1/2] Optimize when scale = 1 --- SDWebImage/SDWebImageCompat.m | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/SDWebImage/SDWebImageCompat.m b/SDWebImage/SDWebImageCompat.m index daee7fc9..90b21145 100644 --- a/SDWebImage/SDWebImageCompat.m +++ b/SDWebImage/SDWebImageCompat.m @@ -56,10 +56,12 @@ inline UIImage *SDScaledImageForKey(NSString * _Nullable key, UIImage * _Nullabl scale = 3.0; } } - - UIImage *scaledImage = [[UIImage alloc] initWithCGImage:image.CGImage scale:scale orientation:image.imageOrientation]; - scaledImage.sd_imageFormat = image.sd_imageFormat; - image = scaledImage; + + if (scale != 1) { + UIImage *scaledImage = [[UIImage alloc] initWithCGImage:image.CGImage scale:scale orientation:image.imageOrientation]; + scaledImage.sd_imageFormat = image.sd_imageFormat; + image = scaledImage; + } } return image; } From 2ac9b2fc6acf864437fa61668840e10aa81aec35 Mon Sep 17 00:00:00 2001 From: Noah Date: Tue, 30 Oct 2018 15:00:25 +0800 Subject: [PATCH 2/2] Update SDWebImage/SDWebImageCompat.m --- SDWebImage/SDWebImageCompat.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SDWebImage/SDWebImageCompat.m b/SDWebImage/SDWebImageCompat.m index 90b21145..ffde1d22 100644 --- a/SDWebImage/SDWebImageCompat.m +++ b/SDWebImage/SDWebImageCompat.m @@ -57,7 +57,7 @@ inline UIImage *SDScaledImageForKey(NSString * _Nullable key, UIImage * _Nullabl } } - if (scale != 1) { + if (scale != image.scale) { UIImage *scaledImage = [[UIImage alloc] initWithCGImage:image.CGImage scale:scale orientation:image.imageOrientation]; scaledImage.sd_imageFormat = image.sd_imageFormat; image = scaledImage;