File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
Sources/ComposableArchitecture/SwiftUI Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change 95
95
{
96
96
self . data = store. state
97
97
self . content = {
98
- WithViewStore ( store. scope ( state: { $0. ids } ) ) { viewStore in
98
+ WithViewStore (
99
+ store. scope ( state: { $0. ids } ) ,
100
+ removeDuplicates: areOrderedSetsDuplicates
101
+ ) { viewStore in
99
102
ForEach ( viewStore. state, id: \. self) { id -> EachContent in
100
103
// NB: We cache elements here to avoid a potential crash where SwiftUI may re-evaluate
101
104
// views for elements no longer in the collection.
120
123
self . content ( )
121
124
}
122
125
}
126
+
127
+ private func areOrderedSetsDuplicates< ID: Hashable > ( lhs: OrderedSet < ID > , rhs: OrderedSet < ID > ) -> Bool {
128
+ var lhs = lhs
129
+ var rhs = rhs
130
+ if memcmp ( & lhs, & rhs, MemoryLayout< OrderedSet< ID>>. size) == 0 {
131
+ return true
132
+ }
133
+ return lhs == rhs
134
+ }
123
135
#endif
You can’t perform that action at this time.
0 commit comments