Skip to content

Commit

Permalink
refactor: [trivial] replace.rs: use HugrView::first_child (#1737)
Browse files Browse the repository at this point in the history
Missed from #1721 but this is exactly the kind of code that
`first_child` was intended to handle.
  • Loading branch information
acl-cqc authored Dec 3, 2024
1 parent f5af79c commit 04073ca
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions hugr-core/src/hugr/rewrite/replace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,11 +314,7 @@ impl Rewrite for Replacement {
for (new_parent, &old_parent) in self.adoptions.iter() {
let new_parent = node_map.get(new_parent).unwrap();
debug_assert!(h.children(old_parent).next().is_some());
loop {
let ch = match h.children(old_parent).next() {
None => break,
Some(c) => c,
};
while let Some(ch) = h.first_child(old_parent) {
h.set_parent(ch, *new_parent);
}
}
Expand Down

0 comments on commit 04073ca

Please sign in to comment.