Skip to content

Commit

Permalink
Use GlobalCurve identity for iter dedup
Browse files Browse the repository at this point in the history
  • Loading branch information
hannobraun committed Sep 27, 2022
1 parent 2fa1396 commit ec4b3c2
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion crates/fj-kernel/src/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pub trait ObjectIters<'r> {
let mut iter = Iter::empty();

for object in self.referenced_objects() {
iter = iter.with(object.global_curve_iter());
iter = iter.with_handles(object.global_curve_iter());
}

iter
Expand Down Expand Up @@ -337,6 +337,18 @@ impl<T> Iter<T> {
}
}

impl<T> Iter<&'_ Handle<T>> {
fn with_handles(mut self, other: Self) -> Self {
for handle in other {
if !self.0.iter().any(|h| h.id() == handle.id()) {
self.0.push_back(handle);
}
}

self
}
}

impl<T> Iterator for Iter<T> {
type Item = T;

Expand Down

0 comments on commit ec4b3c2

Please sign in to comment.