mirror of
https://github.com/roc-lang/roc.git
synced 2024-11-11 05:34:11 +03:00
slightly optimize rank calculation
This commit is contained in:
parent
5372c45cdd
commit
0ec1c49042
@ -1135,16 +1135,20 @@ fn adjust_rank_content(
|
|||||||
}
|
}
|
||||||
|
|
||||||
RecursiveTagUnion(rec_var, tags, ext_var) => {
|
RecursiveTagUnion(rec_var, tags, ext_var) => {
|
||||||
let mut rank = adjust_rank(subs, young_mark, visit_mark, group_rank, *rec_var);
|
let mut rank = adjust_rank(subs, young_mark, visit_mark, group_rank, *ext_var);
|
||||||
rank = rank.max(adjust_rank(
|
|
||||||
subs, young_mark, visit_mark, group_rank, *ext_var,
|
|
||||||
));
|
|
||||||
|
|
||||||
for var in tags.values().flatten() {
|
for var in tags.values().flatten() {
|
||||||
rank =
|
rank =
|
||||||
rank.max(adjust_rank(subs, young_mark, visit_mark, group_rank, *var));
|
rank.max(adjust_rank(subs, young_mark, visit_mark, group_rank, *var));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// THEORY: the recursion var has the same rank as the tag union itself
|
||||||
|
// all types it uses are also in the tags already, so it cannot influence the
|
||||||
|
// rank
|
||||||
|
debug_assert!(
|
||||||
|
rank >= adjust_rank(subs, young_mark, visit_mark, group_rank, *rec_var)
|
||||||
|
);
|
||||||
|
|
||||||
rank
|
rank
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1214,16 +1214,20 @@ fn adjust_rank_content(
|
|||||||
}
|
}
|
||||||
|
|
||||||
RecursiveTagUnion(rec_var, tags, ext_var) => {
|
RecursiveTagUnion(rec_var, tags, ext_var) => {
|
||||||
let mut rank = adjust_rank(subs, young_mark, visit_mark, group_rank, *rec_var);
|
let mut rank = adjust_rank(subs, young_mark, visit_mark, group_rank, *ext_var);
|
||||||
rank = rank.max(adjust_rank(
|
|
||||||
subs, young_mark, visit_mark, group_rank, *ext_var,
|
|
||||||
));
|
|
||||||
|
|
||||||
for var in tags.values().flatten() {
|
for var in tags.values().flatten() {
|
||||||
rank =
|
rank =
|
||||||
rank.max(adjust_rank(subs, young_mark, visit_mark, group_rank, *var));
|
rank.max(adjust_rank(subs, young_mark, visit_mark, group_rank, *var));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// THEORY: the recursion var has the same rank as the tag union itself
|
||||||
|
// all types it uses are also in the tags already, so it cannot influence the
|
||||||
|
// rank
|
||||||
|
debug_assert!(
|
||||||
|
rank >= adjust_rank(subs, young_mark, visit_mark, group_rank, *rec_var)
|
||||||
|
);
|
||||||
|
|
||||||
rank
|
rank
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user