From e6a4e74ed57234701267909151783a5422f355b8 Mon Sep 17 00:00:00 2001 From: DreamPiggy Date: Thu, 3 Jan 2019 11:49:06 +0800 Subject: [PATCH] Revert the changes for unused public API, polish comments --- SDWebImage/SDImageCache.h | 11 ----------- SDWebImage/SDImageCache.m | 12 ------------ SDWebImage/UIImage+CacheMemoryCost.h | 10 ++++++---- Tests/SDWebImage Tests.xcodeproj/project.pbxproj | 16 ---------------- 4 files changed, 6 insertions(+), 43 deletions(-) diff --git a/SDWebImage/SDImageCache.h b/SDWebImage/SDImageCache.h index 6004c3b5..ce259897 100644 --- a/SDWebImage/SDImageCache.h +++ b/SDWebImage/SDImageCache.h @@ -160,17 +160,6 @@ typedef void(^SDWebImageCalculateSizeBlock)(NSUInteger fileCount, NSUInteger tot */ - (void)storeImageDataToDisk:(nullable NSData *)imageData forKey:(nullable NSString *)key; -#pragma mark - Update Ops - -/** - * Update image memory cost if image already be stored in memory. - * - * - * @param key The unique image cache key, usually it's image absolute URL - * @note After image be stored in memory cache, if image's memory size changes, such as set a large memory associated object to it, or subclass `UIImage` which has its own large memory properties, you can use this to update memory cost which can make memory cache handle `maxMemoryCost` correctly - */ -- (void)updateImageMemoryCostWithKey:(nullable NSString *)key; - #pragma mark - Query and Retrieve Ops /** diff --git a/SDWebImage/SDImageCache.m b/SDWebImage/SDImageCache.m index 9f931956..edf2377a 100644 --- a/SDWebImage/SDImageCache.m +++ b/SDWebImage/SDImageCache.m @@ -359,18 +359,6 @@ } } -#pragma mark - Update Ops - -- (void)updateImageMemoryCostWithKey:(NSString *)key { - UIImage *cachedImage = [self imageFromMemoryCacheForKey:key]; - // If image can be find in memory cache, we update the cost value of cost. - if (cachedImage) { - [self removeImageForKey:key fromDisk:NO withCompletion:^{ - [self storeImage:cachedImage forKey:key toDisk:NO completion:nil]; - }]; - } -} - #pragma mark - Query and Retrieve Ops - (void)diskImageExistsWithKey:(nullable NSString *)key completion:(nullable SDWebImageCheckCacheCompletionBlock)completionBlock { diff --git a/SDWebImage/UIImage+CacheMemoryCost.h b/SDWebImage/UIImage+CacheMemoryCost.h index 480230e9..10fa87d9 100644 --- a/SDWebImage/UIImage+CacheMemoryCost.h +++ b/SDWebImage/UIImage+CacheMemoryCost.h @@ -11,10 +11,12 @@ @interface UIImage (CacheMemoryCost) /** - * The image memory cost calculation, this property would be used in memory cache of `SDImageCache`. - * The default value is pixels of `image` or `images`. - * If you set some associated object to `UIImage`, you can set the custom value to indicate the memory cost. - * If you set a new value after `UIImage` be cached to memory cache, you need to reinsert into cache with new value cost by yourself. + The memory cache cost for specify image used by image cache. The cost function is the pixles count held in memory. + If you set some associated object to `UIImage`, you can set the custom value to indicate the memory cost. + + For `UIImage`, this method return the single frame pixles count when `image.images` is nil for static image. Retuen full frame pixels count when `image.images` is not nil for animated image. + For `NSImage`, this method return the single frame pixels count because `NSImage` does not store all frames in memory. + @note Note that because of the limitations of categories this property can get out of sync if you create another instance with CGImage or other methods. */ @property (assign, nonatomic) NSUInteger sd_memoryCost; diff --git a/Tests/SDWebImage Tests.xcodeproj/project.pbxproj b/Tests/SDWebImage Tests.xcodeproj/project.pbxproj index 8013ef4d..5330f6af 100644 --- a/Tests/SDWebImage Tests.xcodeproj/project.pbxproj +++ b/Tests/SDWebImage Tests.xcodeproj/project.pbxproj @@ -159,7 +159,6 @@ DA248D50195472AA00390AB0 /* Frameworks */, DA248D51195472AA00390AB0 /* Resources */, C86216497B5A0BA9501E2C07 /* [CP] Embed Pods Frameworks */, - 85E5D3885A03BFC23B050908 /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -232,21 +231,6 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; - 85E5D3885A03BFC23B050908 /* [CP] Copy Pods Resources */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "[CP] Copy Pods Resources"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Tests/Pods-Tests-resources.sh\"\n"; - showEnvVarsInLog = 0; - }; C86216497B5A0BA9501E2C07 /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647;