- Authors: Justin Reusch
Swift has a focus on being fast and efficient. To this goal, the memoization of computed properties would help to speed up some Swift programs relying on computed values (especially expensive ones) by only re-calculating the results when one of the properties they depend on has changed.
Anyone familiar with React and React hooks will know one of the most useful hooks is useMemo
, which provides this exact functionality for rendering UIs. While memoization would be broadly applicable to any Swift program, it may be especially helpful for use in SwiftUI, where preventing unnecessary re-renders can help optimize app performance.
Swift's use of computed properties is extremely convenient for dynamic properties that are derived from other properties and/or subject to change. That said, they can have a performance drawback if the programm