From bc430e018aac9c56f4663c1dc67690f724b2a8ae Mon Sep 17 00:00:00 2001 From: onevcat Date: Tue, 14 Nov 2017 10:55:52 +0900 Subject: [PATCH] No need to encode images again No need to encode images again when original data provided. --- Sources/CacheSerializer.swift | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/Sources/CacheSerializer.swift b/Sources/CacheSerializer.swift index 84073a368..9a222f12b 100644 --- a/Sources/CacheSerializer.swift +++ b/Sources/CacheSerializer.swift @@ -63,17 +63,8 @@ public struct DefaultCacheSerializer: CacheSerializer { private init() {} public func data(with image: Image, original: Data?) -> Data? { - let imageFormat = original?.kf.imageFormat ?? .unknown - - let data: Data? - switch imageFormat { - case .PNG: data = image.kf.pngRepresentation() - case .JPEG: data = image.kf.jpegRepresentation(compressionQuality: 1.0) - case .GIF: data = image.kf.gifRepresentation() - case .unknown: data = original ?? image.kf.normalized.kf.pngRepresentation() - } - - return data + // If original data is provided, just use it. + return original ?? image.kf.normalized.kf.pngRepresentation() } public func image(with data: Data, options: KingfisherOptionsInfo?) -> Image? {