-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Perf] Do more diffing work on a background queue (#137)
This re-works `DiffableDataSource` to perform more operations on a background thread — namely building the initial snapshot and searching for items that need to be reconfigured. In extremely large collections, performing these operations on the main thread can produce noticeable lag. ### `Sendable` changes This also makes `DiffableViewModel` inherit from `Sendable`, which means this also applies to `CellViewModel`, `SupplementaryViewModel`, `SectionViewModel`, and `CollectionViewModel`. Early in development, I avoided doing this because I did not want to place the burden of `Sendable` on clients. Instead, I opted to make everything `@MainActor` (which is also a burden, in different ways). However, that was changed in #135. After the performance improvements in faabe72, making these types `Sendable` is more necessary. However, I think we can justify making all view models `Sendable` because all the view models _should_ be stateless / immutable. If you want to update the collection view, then you need to apply a new view model via `update(viewModel:)` — so it's not as if you could be mutating view model state outside of the `Driver` because those changes would not be reflected anyway. ### Swift 6 The only issue with adopting Swift 6 right now is that [`apply(_:animatingDifferences:completion:)`](https://developer.apple.com/documentation/uikit/uicollectionviewdiffabledatasource/3375795-apply) is incorrectly marked as `@MainActor`, which becomes an error in Swift 6. See #116. Otherwise, the library compiles successfully with Swift 6 and complete concurrency checking. 🎉
- Loading branch information
1 parent
bbd57e6
commit 193e123
Showing
5 changed files
with
140 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters