Delete unneeded IconScalerQueue.

This commit is contained in:
Brent Simmons 2024-04-16 22:45:10 -07:00
parent 167e8c1430
commit d4c923a3d6
2 changed files with 4 additions and 35 deletions

View File

@ -109,7 +109,7 @@ public protocol FaviconDownloaderDelegate {
}
if let iconImage = favicon(for: feed), let imageData = iconImage.image.dataRepresentation() {
if let scaledImage = RSImage.scaledForIcon(imageData) {
if let scaledImage = RSImage.scaledForIconSync(imageData) {
let scaledIconImage = IconImage(scaledImage)
cache[feed] = scaledIconImage
return scaledIconImage
@ -164,7 +164,7 @@ public protocol FaviconDownloaderDelegate {
@objc func didLoadFavicon(_ note: Notification) {
assert(Thread.isMainThread)
guard let singleFaviconDownloader = note.object as? SingleFaviconDownloader else {
return
}

View File

@ -29,10 +29,10 @@ extension RSImage {
static func scaledForIcon(_ data: Data) async -> RSImage? {
await IconScalerQueue.shared.scaledForIcon(data)
RSImage.scaledForIconSync(data)
}
static func scaledForIcon(_ data: Data) -> RSImage? {
static func scaledForIconSync(_ data: Data) -> RSImage? {
guard var cgImage = RSImage.scaleImage(data, maxPixelSize: Self.scaledMaxPixelSize) else {
return nil
@ -46,34 +46,3 @@ extension RSImage {
#endif
}
}
// MARK: - IconScalerQueue
private final class IconScalerQueue: @unchecked Sendable {
static let shared = IconScalerQueue()
private let queue: DispatchQueue = {
let q = DispatchQueue(label: "IconScaler", attributes: .initiallyInactive)
q.setTarget(queue: DispatchQueue.global(qos: .default))
q.activate()
return q
}()
private func scaledForIcon(_ data: Data, _ imageResultBlock: @escaping ImageResultBlock) {
queue.async {
let image = RSImage.scaledForIcon(data)
imageResultBlock(image)
}
}
func scaledForIcon(_ data: Data) async -> RSImage? {
await withCheckedContinuation { continuation in
self.scaledForIcon(data) { image in
continuation.resume(returning: image)
}
}
}
}