From 75d3adedfa99fa3179470b72f3863163f6d1dd78 Mon Sep 17 00:00:00 2001 From: DreamPiggy Date: Sun, 31 Mar 2019 18:09:17 +0800 Subject: [PATCH] Update the coders manager initializer, without the useless mutable copy Update the comments --- SDWebImage/SDImageCachesManager.m | 4 ++-- SDWebImage/SDImageCodersManager.h | 6 +++--- SDWebImage/SDImageCodersManager.m | 3 +-- SDWebImage/SDImageLoadersManager.m | 4 ++-- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/SDWebImage/SDImageCachesManager.m b/SDWebImage/SDImageCachesManager.m index 1ef33e85..52694704 100644 --- a/SDWebImage/SDImageCachesManager.m +++ b/SDWebImage/SDImageCachesManager.m @@ -36,8 +36,8 @@ self.containsOperationPolicy = SDImageCachesManagerOperationPolicySerial; self.clearOperationPolicy = SDImageCachesManagerOperationPolicyConcurrent; // initialize with default image caches - self.caches = @[[SDImageCache sharedImageCache]]; - self.cachesLock = dispatch_semaphore_create(1); + _caches = @[[SDImageCache sharedImageCache]]; + _cachesLock = dispatch_semaphore_create(1); } return self; } diff --git a/SDWebImage/SDImageCodersManager.h b/SDWebImage/SDImageCodersManager.h index e4276464..cd77091a 100644 --- a/SDWebImage/SDImageCodersManager.h +++ b/SDWebImage/SDImageCodersManager.h @@ -17,10 +17,10 @@ Note: the `coders` getter will return the coders in their reversed order Example: - - by default we internally set coders = `IOCoder`, `GIFCoder` - - calling `coders` will return `@[IOCoder, GIFCoder]` + - by default we internally set coders = `IOCoder`, `GIFCoder`, `APNGCoder` + - calling `coders` will return `@[IOCoder, GIFCoder, APNGCoder]` - call `[addCoder:[MyCrazyCoder new]]` - - calling `coders` now returns `@[IOCoder, GIFCoder, MyCrazyCoder]` + - calling `coders` now returns `@[IOCoder, GIFCoder, APNGCoder, MyCrazyCoder]` Coders ------ diff --git a/SDWebImage/SDImageCodersManager.m b/SDWebImage/SDImageCodersManager.m index 77522cd4..e358542b 100644 --- a/SDWebImage/SDImageCodersManager.m +++ b/SDWebImage/SDImageCodersManager.m @@ -31,8 +31,7 @@ - (instancetype)init { if (self = [super init]) { // initialize with default coders - NSMutableArray> *mutableCoders = [@[[SDImageIOCoder sharedCoder], [SDImageGIFCoder sharedCoder], [SDImageAPNGCoder sharedCoder]] mutableCopy]; - _coders = [mutableCoders copy]; + _coders = @[[SDImageIOCoder sharedCoder], [SDImageGIFCoder sharedCoder], [SDImageAPNGCoder sharedCoder]]; _codersLock = dispatch_semaphore_create(1); } return self; diff --git a/SDWebImage/SDImageLoadersManager.m b/SDWebImage/SDImageLoadersManager.m index 04607439..ecb476c5 100644 --- a/SDWebImage/SDImageLoadersManager.m +++ b/SDWebImage/SDImageLoadersManager.m @@ -30,8 +30,8 @@ self = [super init]; if (self) { // initialize with default image loaders - self.loaders = @[[SDWebImageDownloader sharedDownloader]]; - self.loadersLock = dispatch_semaphore_create(1); + _loaders = @[[SDWebImageDownloader sharedDownloader]]; + _loadersLock = dispatch_semaphore_create(1); } return self; }