From 1fa4cc4f53079f2d823cd3146a9a34fd2d1f57f7 Mon Sep 17 00:00:00 2001 From: tibvdm Date: Fri, 23 Aug 2024 14:45:08 +0200 Subject: [PATCH] use references instead of cloning the data --- api/src/helpers/fa_helper.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/api/src/helpers/fa_helper.rs b/api/src/helpers/fa_helper.rs index cf09d85..b5bb18d 100644 --- a/api/src/helpers/fa_helper.rs +++ b/api/src/helpers/fa_helper.rs @@ -14,12 +14,12 @@ pub struct FunctionalAggregation { pub fn calculate_fa(proteins: &[ProteinInfo]) -> FunctionalAggregation { // Keep track of the proteins that have any annotation - let mut proteins_with_annotations: HashSet = HashSet::new(); + let mut proteins_with_annotations: HashSet<&str> = HashSet::new(); // Keep track of the proteins that have a certain annotation - let mut proteins_with_ec: HashSet = HashSet::new(); - let mut proteins_with_go: HashSet = HashSet::new(); - let mut proteins_with_ipr: HashSet = HashSet::new(); + let mut proteins_with_ec: HashSet<&str> = HashSet::new(); + let mut proteins_with_go: HashSet<&str> = HashSet::new(); + let mut proteins_with_ipr: HashSet<&str> = HashSet::new(); // Keep track of the counts of the different annotations let mut data: HashMap = HashMap::new(); @@ -28,16 +28,16 @@ pub fn calculate_fa(proteins: &[ProteinInfo]) -> FunctionalAggregation { for annotation in protein.functional_annotations.split(';') { match annotation.chars().next() { Some('E') => { - proteins_with_ec.insert(protein.uniprot_accession.clone()); - proteins_with_annotations.insert(protein.uniprot_accession.clone()); + proteins_with_ec.insert(&protein.uniprot_accession); + proteins_with_annotations.insert(&protein.uniprot_accession); } Some('G') => { - proteins_with_go.insert(protein.uniprot_accession.clone()); - proteins_with_annotations.insert(protein.uniprot_accession.clone()); + proteins_with_go.insert(&protein.uniprot_accession); + proteins_with_annotations.insert(&protein.uniprot_accession); } Some('I') => { - proteins_with_ipr.insert(protein.uniprot_accession.clone()); - proteins_with_annotations.insert(protein.uniprot_accession.clone()); + proteins_with_ipr.insert(&protein.uniprot_accession); + proteins_with_annotations.insert(&protein.uniprot_accession); } _ => {} };