mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 22:34:45 +00:00
get fancy, store variable directly in the index
This commit is contained in:
parent
b3d9f9c2de
commit
eccb461b01
2 changed files with 6 additions and 3 deletions
|
@ -125,7 +125,10 @@ impl Constraints {
|
|||
Type::EmptyRec => EitherIndex::from_left(Self::EMPTY_RECORD),
|
||||
Type::EmptyTagUnion => EitherIndex::from_left(Self::EMPTY_TAG_UNION),
|
||||
Type::Variable(var) => {
|
||||
let index: Index<Variable> = Index::push_new(&mut self.variables, var);
|
||||
// that's right, we use the variable's integer value as the index
|
||||
// that way, we don't need to push anything onto a vector
|
||||
let index: Index<Variable> = Index::new(var.index());
|
||||
|
||||
EitherIndex::from_right(index)
|
||||
}
|
||||
other => {
|
||||
|
|
|
@ -890,8 +890,8 @@ fn either_type_index_to_var(
|
|||
type_to_var(subs, rank, pools, _alias_map, typ)
|
||||
}
|
||||
Err(var_index) => {
|
||||
let var = constraints.variables[var_index.index()];
|
||||
var
|
||||
// we cheat, and store the variable directly in the index
|
||||
unsafe { Variable::from_index(var_index.index() as _) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue