diff --git a/compiler/can/src/constraint.rs b/compiler/can/src/constraint.rs index 8ffd1ec896..ae24ba78c9 100644 --- a/compiler/can/src/constraint.rs +++ b/compiler/can/src/constraint.rs @@ -172,6 +172,7 @@ impl Constraints { } } + #[inline(always)] pub fn equal_types( &mut self, typ: Type, @@ -262,9 +263,15 @@ impl Constraints { fn def_types_slice(&mut self, it: I) -> Slice<(Symbol, Loc>)> where I: IntoIterator)>, + I::IntoIter: ExactSizeIterator, { + let it = it.into_iter(); + let start = self.def_types.len(); + // because we have an ExactSizeIterator, we can reserve space here + self.def_types.reserve(it.len()); + for (symbol, loc_type) in it { let Loc { region, value } = loc_type; let type_index = Index::push_new(&mut self.types, value); @@ -277,6 +284,7 @@ impl Constraints { Slice::new(start as _, length as _) } + #[inline(always)] pub fn exists(&mut self, flex_vars: I, defs_constraint: Constraint) -> Constraint where I: IntoIterator, @@ -299,6 +307,7 @@ impl Constraints { Constraint::Let(let_index) } + #[inline(always)] pub fn exists_many(&mut self, flex_vars: I, defs_constraint: C) -> Constraint where I: IntoIterator, @@ -324,6 +333,7 @@ impl Constraints { Constraint::Let(let_index) } + #[inline(always)] pub fn let_constraint( &mut self, rigid_vars: I1, @@ -336,6 +346,7 @@ impl Constraints { I1: IntoIterator, I2: IntoIterator, I3: IntoIterator)>, + I3::IntoIter: ExactSizeIterator, { let defs_and_ret_constraint = Index::new(self.constraints.len() as _); @@ -355,6 +366,7 @@ impl Constraints { Constraint::Let(let_index) } + #[inline(always)] pub fn and_constraint(&mut self, constraints: I) -> Constraint where I: IntoIterator,