From 3e78e29480780c8e4711fbf6dd8b3c21974a631c Mon Sep 17 00:00:00 2001 From: Bogdan Poplauschi Date: Fri, 23 Sep 2016 23:43:06 +0300 Subject: [PATCH] Pragma marks for code readability --- SDWebImage/SDImageCache.h | 11 +++++++++-- SDWebImage/SDImageCache.m | 10 +++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/SDWebImage/SDImageCache.h b/SDWebImage/SDImageCache.h index cf87c62f..f308689c 100644 --- a/SDWebImage/SDImageCache.h +++ b/SDWebImage/SDImageCache.h @@ -146,7 +146,7 @@ typedef void(^SDWebImageCalculateSizeBlock)(NSUInteger fileCount, NSUInteger tot */ - (void)storeImageDataToDisk:(nullable NSData *)imageData forKey:(nullable NSString *)key; -#pragma mark - Query Ops +#pragma mark - Query and Retrieve Ops /** * Operation that queries the cache asynchronously and call the completion when done. @@ -179,6 +179,8 @@ typedef void(^SDWebImageCalculateSizeBlock)(NSUInteger fileCount, NSUInteger tot */ - (nullable UIImage *)imageFromCacheForKey:(nullable NSString *)key; +#pragma mark - Remove Ops + /** * Remove the image from memory and disk cache asynchronously * @@ -186,7 +188,6 @@ typedef void(^SDWebImageCalculateSizeBlock)(NSUInteger fileCount, NSUInteger tot */ - (void)removeImageForKey:(nullable NSString *)key; - /** * Remove the image from memory and disk cache asynchronously * @@ -212,6 +213,8 @@ typedef void(^SDWebImageCalculateSizeBlock)(NSUInteger fileCount, NSUInteger tot */ - (void)removeImageForKey:(nullable NSString *)key fromDisk:(BOOL)fromDisk withCompletion:(nullable SDWebImageNoParamsBlock)completion; +#pragma mark - Cache clean Ops + /** * Clear all memory cached images */ @@ -229,6 +232,8 @@ typedef void(^SDWebImageCalculateSizeBlock)(NSUInteger fileCount, NSUInteger tot */ - (void)deleteOldFilesWithCompletionBlock:(nullable SDWebImageNoParamsBlock)completionBlock; +#pragma mark - Cache Info + /** * Get the size used by the disk cache */ @@ -253,6 +258,8 @@ typedef void(^SDWebImageCalculateSizeBlock)(NSUInteger fileCount, NSUInteger tot */ - (void)diskImageExistsWithKey:(nullable NSString *)key completion:(nullable SDWebImageCheckCacheCompletionBlock)completionBlock; +#pragma mark - Cache Paths + /** * Get the cache path for a certain key (needs the cache path root folder) * diff --git a/SDWebImage/SDImageCache.m b/SDWebImage/SDImageCache.m index 97b07a03..531e17c3 100644 --- a/SDWebImage/SDImageCache.m +++ b/SDWebImage/SDImageCache.m @@ -275,7 +275,7 @@ FOUNDATION_STATIC_INLINE NSUInteger SDCacheCostForImage(UIImage *image) { }); } -#pragma mark - Query Ops +#pragma mark - Query and Retrieve Ops - (nullable UIImage *)imageFromMemoryCacheForKey:(nullable NSString *)key { return [self.memCache objectForKey:key]; @@ -402,6 +402,8 @@ FOUNDATION_STATIC_INLINE NSUInteger SDCacheCostForImage(UIImage *image) { return operation; } +#pragma mark - Remove Ops + - (void)removeImageForKey:(nullable NSString *)key { [self removeImageForKey:key withCompletion:nil]; } @@ -440,6 +442,8 @@ FOUNDATION_STATIC_INLINE NSUInteger SDCacheCostForImage(UIImage *image) { } +# pragma mark - Mem Cache settings + - (void)setMaxMemoryCost:(NSUInteger)maxMemoryCost { self.memCache.totalCostLimit = maxMemoryCost; } @@ -456,6 +460,8 @@ FOUNDATION_STATIC_INLINE NSUInteger SDCacheCostForImage(UIImage *image) { self.memCache.countLimit = maxCountLimit; } +#pragma mark - Cache clean Ops + - (void)clearMemory { [self.memCache removeAllObjects]; } @@ -580,6 +586,8 @@ FOUNDATION_STATIC_INLINE NSUInteger SDCacheCostForImage(UIImage *image) { } #endif +#pragma mark - Cache Info + - (NSUInteger)getSize { __block NSUInteger size = 0; dispatch_sync(self.ioQueue, ^{