Skip to content

Commit

Permalink
refactor: use break-label to break nested loop
Browse files Browse the repository at this point in the history
  • Loading branch information
soul committed Feb 24, 2024
1 parent ce774bc commit 74edff5
Showing 1 changed file with 8 additions and 21 deletions.
29 changes: 8 additions & 21 deletions src-tauri/src/structs/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,38 +224,25 @@ impl Queue {
Ok(mut config_json) => {
for ri in result_queue {
let insert_node_id = &ri.category_id;
let mut find = false;

for project in &mut config_json.project_list {
if find {
break;
}

'project: for project in &mut config_json.project_list {
for category in &mut project.categories {
if find {
break;
}

if category.id.as_str() == insert_node_id.as_str() {
for interface in &mut category.interfaces {
if interface.id == ri.id {
interface.name = Some(ri.title.clone());
interface.path = Some(ri.path.clone());

find = true;
break;
break 'project;
}
}

if !find {
category.interfaces.push(InterfaceShort {
id: ri.id.clone(),
name: Some(ri.title.clone()),
path: Some(ri.path.clone())
});
}
category.interfaces.push(InterfaceShort {
id: ri.id.clone(),
name: Some(ri.title.clone()),
path: Some(ri.path.clone()),
});

find = true;
break 'project;
}
}
}
Expand Down

0 comments on commit 74edff5

Please sign in to comment.