From ce4f47d2e99e85ff285129d530d1562e930ca8aa Mon Sep 17 00:00:00 2001 From: Folkert Date: Sat, 19 Mar 2022 00:03:30 +0100 Subject: [PATCH] remove clones in IntroducedVariables clone --- compiler/can/src/annotation.rs | 11 +++++++++++ compiler/can/src/expr.rs | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/compiler/can/src/annotation.rs b/compiler/can/src/annotation.rs index 86eceda3ec..0525d6869e 100644 --- a/compiler/can/src/annotation.rs +++ b/compiler/can/src/annotation.rs @@ -80,6 +80,17 @@ impl IntroducedVariables { 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> { self.named .iter() diff --git a/compiler/can/src/expr.rs b/compiler/can/src/expr.rs index a1f9510b83..a579f5094d 100644 --- a/compiler/can/src/expr.rs +++ b/compiler/can/src/expr.rs @@ -40,7 +40,8 @@ impl Output { 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.non_closures.extend(other.non_closures); }