Skip to content

Commit e025a93

Browse files
committed
Code review cleanup
1 parent af7cefc commit e025a93

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

editor/src/messages/portfolio/document/utility_types/network_interface.rs

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4603,35 +4603,36 @@ impl NodeNetworkInterface {
46034603

46044604
if !delete_children {
46054605
continue;
4606-
};
4606+
}
46074607

4608-
// Perform an upstream traversal to try delete children
4608+
// Perform an upstream traversal to try deleting children
46094609
for upstream_id in self.upstream_flow_back_from_nodes(vec![*node_id], network_path, FlowType::LayerChildrenUpstreamFlow) {
4610-
// For each potential child perform a complete downstream traveral, ending at either a node in the `delete_nodes` set, the output, or a dead end.
4611-
// If the output node is eventually reached, then it is not a sole dependent and will not be deleted
4610+
// For each potential child: perform a complete downstream traveral, ending at either a node in the `delete_nodes` set, the output, or a dead end.
4611+
// If the output node is eventually reached, then it is not a sole dependent and will not be deleted.
46124612
let mut stack = vec![OutputConnector::node(upstream_id, 0)];
46134613
let mut can_delete = true;
4614+
46144615
while let Some(current_node) = stack.pop() {
4615-
let current_node_id = current_node.node_id().expect("The current node in the delete stack cannot be the export");
46164616
let Some(downstream_nodes) = outward_wires.get(&current_node) else { continue };
4617+
46174618
// If there are no outward wires, then we have reached a dead end, and the node cannot be deleted
46184619
if downstream_nodes.is_empty() {
46194620
can_delete = false;
46204621
break;
46214622
}
4623+
46224624
for downstream_node in downstream_nodes {
4623-
if let InputConnector::Node { node_id: downstream_id, .. } = downstream_node {
4624-
// If the downstream node is not in the delete nodes set, then continue iterating
4625-
if !delete_nodes.contains(downstream_id) {
4626-
for output_index in 0..self.number_of_outputs(downstream_id, network_path) {
4627-
stack.push(OutputConnector::node(*downstream_id, output_index))
4628-
}
4629-
}
4630-
}
46314625
// If the traversal reaches the export, then the current node is not a sole dependent and cannot be deleted
4632-
else {
4626+
let InputConnector::Node { node_id: downstream_id, .. } = downstream_node else {
46334627
can_delete = false;
46344628
break;
4629+
};
4630+
4631+
// If the downstream node is not in the `delete_nodes` set, then continue iterating
4632+
if !delete_nodes.contains(downstream_id) {
4633+
for output_index in 0..self.number_of_outputs(downstream_id, network_path) {
4634+
stack.push(OutputConnector::node(*downstream_id, output_index));
4635+
}
46354636
}
46364637
}
46374638
}

0 commit comments

Comments
 (0)