Skip to content

Commit

Permalink
Apply guard let shorthand syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-han committed Mar 7, 2024
1 parent df6057f commit 2b32e67
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ ImageDecoderRegistry.shared.register { context in

let url = URL(string: "https://upload.wikimedia.org/wikipedia/commons/9/9d/Swift_logo.svg")
ImagePipeline.shared.loadImage(with: url) { [weak self] result in
guard let self = self, let data = try? result.get().container.data else {
guard let self, let data = try? result.get().container.data else {
return
}
// You can render an image using whatever size you want, vector!
Expand Down
4 changes: 2 additions & 2 deletions Sources/Nuke/Pipeline/ImagePipeline.swift
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ public final class ImagePipeline: @unchecked Sendable {

tasks[task] = makeTaskLoadImage(for: task.request)
.subscribe(priority: task.priority.taskPriority, subscriber: task) { [weak self, weak task] event in
guard let self = self, let task = task else { return }
guard let self, let task else { return }

if event.isCompleted {
self.tasks[task] = nil
Expand Down Expand Up @@ -425,7 +425,7 @@ public final class ImagePipeline: @unchecked Sendable {

tasks[task] = makeTaskLoadData(for: task.request)
.subscribe(priority: task.priority.taskPriority, subscriber: task) { [weak self, weak task] event in
guard let self = self, let task = task else { return }
guard let self, let task else { return }

if event.isCompleted {
self.tasks[task] = nil
Expand Down
2 changes: 1 addition & 1 deletion Sources/Nuke/Tasks/TaskFetchOriginalImageData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ final class TaskFetchOriginalImageData: ImagePipelineTask<(Data, URLResponse?)>
// Rate limiter is synchronized on pipeline's queue. Delayed work is
// executed asynchronously also on the same queue.
rateLimiter.execute { [weak self] in
guard let self = self, !self.isDisposed else {
guard let self, !self.isDisposed else {
return false
}
self.loadData(urlRequest: urlRequest)
Expand Down
2 changes: 1 addition & 1 deletion Sources/NukeExtensions/ImageViewExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ private final class ImageViewController {
}

// Handle a scenario where request is `nil` (in the same way as a failure)
guard var request = request else {
guard var request else {
if options.isPrepareForReuseEnabled {
imageView.nuke_display(image: nil, data: nil)
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/NukeUI/FetchImage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public final class FetchImage: ObservableObject, Identifiable {

reset()

guard var request = request else {
guard var request else {
handle(result: .failure(ImagePipeline.Error.imageRequestMissing))
return
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/NukeUI/LazyImageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ public final class LazyImageView: _PlatformBaseView {
isResetNeeded = true
}

guard var request = request else {
guard var request else {
handle(result: .failure(ImagePipeline.Error.imageRequestMissing), isSync: true)
return
}
Expand Down

0 comments on commit 2b32e67

Please sign in to comment.