avoid expensive sync disk read
This commit is contained in:
@@ -77,15 +77,11 @@ final class ImagePreviewController: UIViewController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Synchronous cache lookup across memory + disk. Memory hits are instant;
|
/// Memory-only cache lookup. Disk reads are left to the async SDWebImage
|
||||||
/// disk hits incur a small read but remain on-thread (matches what SDWebImage
|
/// load to avoid blocking the main thread during the peek animation.
|
||||||
/// does when the cache policy permits).
|
|
||||||
private func cachedImage(for url: URL) -> UIImage? {
|
private func cachedImage(for url: URL) -> UIImage? {
|
||||||
let key = SDWebImageManager.shared.cacheKey(for: url) ?? url.absoluteString
|
let key = SDWebImageManager.shared.cacheKey(for: url) ?? url.absoluteString
|
||||||
if let memory = SDImageCache.shared.imageFromMemoryCache(forKey: key) {
|
return SDImageCache.shared.imageFromMemoryCache(forKey: key)
|
||||||
return memory
|
|
||||||
}
|
|
||||||
return SDImageCache.shared.imageFromDiskCache(forKey: key)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Caps the preview to a comfortable size within the current key window.
|
/// Caps the preview to a comfortable size within the current key window.
|
||||||
|
|||||||
Reference in New Issue
Block a user