Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace bunch of get(x).is_some() by contains(x) #26

Merged
merged 1 commit into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/cleanup/compu_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ fn remove_unused_compumethods(module: &mut Module) {

module
.compu_method
.retain(|item| used_compumethods.get(&item.name).is_some());
.retain(|item| used_compumethods.contains(&item.name));
}

fn remove_unused_sub_elements(module: &mut Module) {
Expand All @@ -117,13 +117,13 @@ fn remove_unused_sub_elements(module: &mut Module) {

module
.compu_tab
.retain(|item| used_compu_tabs.get(&item.name).is_some());
.retain(|item| used_compu_tabs.contains(&item.name));
module
.compu_vtab
.retain(|item| used_compu_tabs.get(&item.name).is_some());
.retain(|item| used_compu_tabs.contains(&item.name));
module
.compu_vtab_range
.retain(|item| used_compu_tabs.get(&item.name).is_some());
.retain(|item| used_compu_tabs.contains(&item.name));

// remove all unused UNITs
for unit in &module.unit {
Expand All @@ -134,7 +134,7 @@ fn remove_unused_sub_elements(module: &mut Module) {

module
.unit
.retain(|item| used_units.get(&item.name).is_some());
.retain(|item| used_units.contains(&item.name));
}

fn remove_invalid_sub_element_refs(module: &mut Module) {
Expand Down
20 changes: 10 additions & 10 deletions src/cleanup/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,39 +146,39 @@
if let Some(function_list) = &mut axispts.function_list {
function_list
.name_list
.retain(|name| existing_functions.get(name).is_some());
.retain(|name| existing_functions.contains(name));

Check warning on line 149 in src/cleanup/functions.rs

View check run for this annotation

Codecov / codecov/patch

src/cleanup/functions.rs#L149

Added line #L149 was not covered by tests
}
}

for chara in &mut module.characteristic {
if let Some(function_list) = &mut chara.function_list {
function_list
.name_list
.retain(|name| existing_functions.get(name).is_some());
.retain(|name| existing_functions.contains(name));
}
}

for meas in &mut module.measurement {
if let Some(function_list) = &mut meas.function_list {
function_list
.name_list
.retain(|name| existing_functions.get(name).is_some());
.retain(|name| existing_functions.contains(name));
}
}

for group in &mut module.group {
if let Some(function_list) = &mut group.function_list {
function_list
.name_list
.retain(|name| existing_functions.get(name).is_some());
.retain(|name| existing_functions.contains(name));
}
}

for function in &mut module.function {
if let Some(sub_functions) = &mut function.sub_function {
sub_functions
.identifier_list
.retain(|name| existing_functions.get(name).is_some());
.retain(|name| existing_functions.contains(name));
}
}
}
Expand Down Expand Up @@ -210,27 +210,27 @@
if let Some(ref_characteristic) = &mut func.ref_characteristic {
ref_characteristic
.identifier_list
.retain(|ident| object_names.get(ident).is_some());
.retain(|ident| object_names.contains(ident));
}
if let Some(def_characteristic) = &mut func.def_characteristic {
def_characteristic
.identifier_list
.retain(|ident| object_names.get(ident).is_some());
.retain(|ident| object_names.contains(ident));
}
if let Some(in_measurement) = &mut func.in_measurement {
in_measurement
.identifier_list
.retain(|ident| object_names.get(ident).is_some());
.retain(|ident| object_names.contains(ident));
}
if let Some(loc_measurement) = &mut func.loc_measurement {
loc_measurement
.identifier_list
.retain(|ident| object_names.get(ident).is_some());
.retain(|ident| object_names.contains(ident));
}
if let Some(out_measurement) = &mut func.out_measurement {
out_measurement
.identifier_list
.retain(|ident| object_names.get(ident).is_some());
.retain(|ident| object_names.contains(ident));
}
}
}
4 changes: 2 additions & 2 deletions src/cleanup/groups.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ fn remove_invalid_object_references(module: &mut Module) {
// retain only references to existing characteristics
ref_characteristic
.identifier_list
.retain(|item| refnames.get(item).is_some());
.retain(|item| refnames.contains(item));
if ref_characteristic.identifier_list.is_empty() {
grp.ref_characteristic = None;
}
Expand All @@ -29,7 +29,7 @@ fn remove_invalid_object_references(module: &mut Module) {
// retain only references to existing measurements
ref_measurement
.identifier_list
.retain(|item| refnames.get(item).is_some());
.retain(|item| refnames.contains(item));
if ref_measurement.identifier_list.is_empty() {
grp.ref_measurement = None;
}
Expand Down
3 changes: 1 addition & 2 deletions src/cleanup/record_layouts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ pub(crate) fn cleanup(module: &mut Module) {
used_record_layouts.insert(s_rec_layout.name.to_owned());
}
}

// remove all unused RECORD_LAYOUTs
module
.record_layout
.retain(|item| used_record_layouts.get(&item.name).is_some());
.retain(|item| used_record_layouts.contains(&item.name));
}