mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-01 07:41:12 +00:00
constraint.rs tweaks
This commit is contained in:
parent
cad02d878c
commit
dc8a077fff
1 changed files with 12 additions and 0 deletions
|
@ -172,6 +172,7 @@ impl Constraints {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
pub fn equal_types(
|
pub fn equal_types(
|
||||||
&mut self,
|
&mut self,
|
||||||
typ: Type,
|
typ: Type,
|
||||||
|
@ -262,9 +263,15 @@ impl Constraints {
|
||||||
fn def_types_slice<I>(&mut self, it: I) -> Slice<(Symbol, Loc<Index<Type>>)>
|
fn def_types_slice<I>(&mut self, it: I) -> Slice<(Symbol, Loc<Index<Type>>)>
|
||||||
where
|
where
|
||||||
I: IntoIterator<Item = (Symbol, Loc<Type>)>,
|
I: IntoIterator<Item = (Symbol, Loc<Type>)>,
|
||||||
|
I::IntoIter: ExactSizeIterator,
|
||||||
{
|
{
|
||||||
|
let it = it.into_iter();
|
||||||
|
|
||||||
let start = self.def_types.len();
|
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 {
|
for (symbol, loc_type) in it {
|
||||||
let Loc { region, value } = loc_type;
|
let Loc { region, value } = loc_type;
|
||||||
let type_index = Index::push_new(&mut self.types, value);
|
let type_index = Index::push_new(&mut self.types, value);
|
||||||
|
@ -277,6 +284,7 @@ impl Constraints {
|
||||||
Slice::new(start as _, length as _)
|
Slice::new(start as _, length as _)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
pub fn exists<I>(&mut self, flex_vars: I, defs_constraint: Constraint) -> Constraint
|
pub fn exists<I>(&mut self, flex_vars: I, defs_constraint: Constraint) -> Constraint
|
||||||
where
|
where
|
||||||
I: IntoIterator<Item = Variable>,
|
I: IntoIterator<Item = Variable>,
|
||||||
|
@ -299,6 +307,7 @@ impl Constraints {
|
||||||
Constraint::Let(let_index)
|
Constraint::Let(let_index)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
pub fn exists_many<I, C>(&mut self, flex_vars: I, defs_constraint: C) -> Constraint
|
pub fn exists_many<I, C>(&mut self, flex_vars: I, defs_constraint: C) -> Constraint
|
||||||
where
|
where
|
||||||
I: IntoIterator<Item = Variable>,
|
I: IntoIterator<Item = Variable>,
|
||||||
|
@ -324,6 +333,7 @@ impl Constraints {
|
||||||
Constraint::Let(let_index)
|
Constraint::Let(let_index)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
pub fn let_constraint<I1, I2, I3>(
|
pub fn let_constraint<I1, I2, I3>(
|
||||||
&mut self,
|
&mut self,
|
||||||
rigid_vars: I1,
|
rigid_vars: I1,
|
||||||
|
@ -336,6 +346,7 @@ impl Constraints {
|
||||||
I1: IntoIterator<Item = Variable>,
|
I1: IntoIterator<Item = Variable>,
|
||||||
I2: IntoIterator<Item = Variable>,
|
I2: IntoIterator<Item = Variable>,
|
||||||
I3: IntoIterator<Item = (Symbol, Loc<Type>)>,
|
I3: IntoIterator<Item = (Symbol, Loc<Type>)>,
|
||||||
|
I3::IntoIter: ExactSizeIterator,
|
||||||
{
|
{
|
||||||
let defs_and_ret_constraint = Index::new(self.constraints.len() as _);
|
let defs_and_ret_constraint = Index::new(self.constraints.len() as _);
|
||||||
|
|
||||||
|
@ -355,6 +366,7 @@ impl Constraints {
|
||||||
Constraint::Let(let_index)
|
Constraint::Let(let_index)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
pub fn and_constraint<I>(&mut self, constraints: I) -> Constraint
|
pub fn and_constraint<I>(&mut self, constraints: I) -> Constraint
|
||||||
where
|
where
|
||||||
I: IntoIterator<Item = Constraint>,
|
I: IntoIterator<Item = Constraint>,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue