Skip to content

Commit 33f3778

Browse files
committed
BUGFIX: deduping subs
1 parent 963308c commit 33f3778

3 files changed

Lines changed: 6 additions & 419 deletions

File tree

anathema-state/src/store/subscriber.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,18 +214,21 @@ impl Subscribers {
214214
fn insert(&mut self, sub: Subscriber) {
215215
match self {
216216
Self::Empty => *self = Self::One(sub),
217-
Self::One(key) => *self = Self::Arr([*key, sub, Subscriber::MAX], KeyIndex::TWO),
217+
Self::One(key) if *key != sub => *self = Self::Arr([*key, sub, Subscriber::MAX], KeyIndex::TWO),
218218
Self::Arr(arr_keys, index) if *index == KeyIndex::MAX => {
219219
let mut keys = Vec::with_capacity(KeyIndex::max() + 1);
220220
keys.extend_from_slice(arr_keys);
221221
keys.push(sub);
222222
*self = Self::Heap(keys);
223223
}
224-
Self::Arr(keys, index) => {
224+
Self::Arr(keys, index) if !keys.contains(&sub) => {
225225
keys[index.0 as usize] = sub;
226226
index.add();
227227
}
228-
Self::Heap(keys) => keys.push(sub),
228+
Self::Heap(keys) if !keys.contains(&sub) => keys.push(sub),
229+
230+
// The sub is already registered
231+
Self::Arr(..) | Self::One(_) | Self::Heap(_) => (),
229232
}
230233
}
231234

anathema-widgets/src/nodes/loops.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ impl<'bp> For<'bp> {
8282
// then truncate the tree
8383
self.collection.reload(ctx.attribute_storage);
8484
ctx.truncate_children(&mut tree);
85-
// tree.truncate_children();
8685
}
8786
}
8887

0 commit comments

Comments
 (0)