Do intersection with displayed ids instead of checking in loop

This commit is contained in:
Clémentine Urquizar 2021-06-15 17:28:26 +02:00
parent 8d0269fcc4
commit 79a1212ebe
No known key found for this signature in database
GPG Key ID: D8E7CC7422E77E1A

View File

@ -162,6 +162,9 @@ impl Index {
.keys() .keys()
.cloned() .cloned()
.collect::<HashSet<_>>() .collect::<HashSet<_>>()
.intersection(&displayed_ids)
.cloned()
.collect::<HashSet<_>>()
.union(&to_retrieve_ids) .union(&to_retrieve_ids)
.cloned() .cloned()
.sorted() .sorted()
@ -240,9 +243,7 @@ fn parse_formatted_options(
} }
if let Some(id) = fields_ids_map.id(&attr) { if let Some(id) = fields_ids_map.id(&attr) {
if displayed_ids.contains(&id) { formatted_options.insert(id, new_format);
formatted_options.insert(id, new_format);
}
} }
}; };
@ -274,16 +275,14 @@ fn parse_formatted_options(
} }
if let Some(id) = fields_ids_map.id(&attr_name) { if let Some(id) = fields_ids_map.id(&attr_name) {
if displayed_ids.contains(&id) { let mut highlight = false;
let mut highlight = false; if let Some(f) = formatted_options.get(&id) {
if let Some(f) = formatted_options.get(&id) { highlight = f.highlight;
highlight = f.highlight;
}
formatted_options.insert(id, FormatOptions {
highlight,
crop: attr_len,
});
} }
formatted_options.insert(id, FormatOptions {
highlight,
crop: attr_len,
});
} }
} }