remove clones in IntroducedVariables clone

This commit is contained in:
Folkert 2022-03-19 00:03:30 +01:00
parent 4e315797b0
commit ce4f47d2e9
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C
2 changed files with 13 additions and 1 deletions

View file

@ -80,6 +80,17 @@ impl IntroducedVariables {
self.named.dedup_by(|nv1, nv2| nv1.name == nv2.name); self.named.dedup_by(|nv1, nv2| nv1.name == nv2.name);
} }
pub fn union_owned(&mut self, other: Self) {
self.wildcards.extend(other.wildcards);
self.lambda_sets.extend(other.lambda_sets);
self.inferred.extend(other.inferred);
self.host_exposed_aliases.extend(other.host_exposed_aliases);
self.named.extend(other.named);
self.named.sort_by(|nv1, nv2| nv1.name.cmp(&nv2.name));
self.named.dedup_by(|nv1, nv2| nv1.name == nv2.name);
}
pub fn var_by_name(&self, name: &Lowercase) -> Option<&Variable> { pub fn var_by_name(&self, name: &Lowercase) -> Option<&Variable> {
self.named self.named
.iter() .iter()

View file

@ -40,7 +40,8 @@ impl Output {
self.tail_call = Some(later); self.tail_call = Some(later);
} }
self.introduced_variables.union(&other.introduced_variables); self.introduced_variables
.union_owned(other.introduced_variables);
self.aliases.extend(other.aliases); self.aliases.extend(other.aliases);
self.non_closures.extend(other.non_closures); self.non_closures.extend(other.non_closures);
} }