Skip to content

Commit 5df4eb9

Browse files
committed
Add minor performance optimization for onChange(of:perform:task:)
1 parent a8f3be2 commit 5df4eb9

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

Sources/SwiftNavigation/Observe.swift

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -291,23 +291,21 @@ private func onChange(
291291

292292
private func onChange(
293293
of tracking: @escaping @Sendable (_ transaction: UITransaction) -> Void,
294-
perform action: @escaping @Sendable (_ transaction: UITransaction) -> Void,
295-
apply: Bool = true,
294+
perform operation: @escaping @Sendable (_ transaction: UITransaction) -> Void,
296295
task: @escaping @Sendable (
297296
_ transaction: UITransaction,
298297
_ operation: @escaping @Sendable () -> Void
299298
) -> Void
300299
) {
301-
if apply { action(.current) }
300+
operation(.current)
302301

303302
withPerceptionTracking {
304303
tracking(.current)
305304
} onChange: {
306305
task(.current) {
307306
onChange(
308307
of: tracking,
309-
perform: action,
310-
apply: true,
308+
perform: operation,
311309
task: task
312310
)
313311
}

0 commit comments

Comments
 (0)