Skip to content

Instantly share code, notes, and snippets.

@steipete
Created April 16, 2021 12:57
Show Gist options
  • Save steipete/6c430d08bd57b066fada7628d3b8b719 to your computer and use it in GitHub Desktop.
Save steipete/6c430d08bd57b066fada7628d3b8b719 to your computer and use it in GitHub Desktop.
SwiftUI Performance Notes (Adding as I learn)
- Optimize Hashable and Equatable. e.g. if you have an id, just use that - instead of having the system use reflection and diff all properties:
public func hash(into hasher: inout Hasher) {
hasher.combine(id)
}
public static func == (lhs: UserBox, rhs: UserBox) -> Bool {
return lhs.id == rhs.id
}
- Use explicit id on ForEach to optimize diffing
- Use ViewDebug print tools to notice loops/large rebuilds
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment