mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 06:14:46 +00:00
update generalize
This commit is contained in:
parent
4489a308e4
commit
dc155ea95a
1 changed files with 6 additions and 12 deletions
|
@ -2615,23 +2615,17 @@ fn adjust_rank(
|
|||
group_rank: Rank,
|
||||
var: Variable,
|
||||
) -> Rank {
|
||||
let desc = subs.get_ref_mut(var);
|
||||
|
||||
let desc_rank = desc.rank;
|
||||
let desc_mark = desc.mark;
|
||||
let desc_rank = subs.get_rank(var);
|
||||
let desc_mark = subs.get_mark(var);
|
||||
|
||||
if desc_mark == young_mark {
|
||||
// SAFETY: in this function (and functions it calls, we ONLY modify rank and mark, never content!
|
||||
// hence, we can have an immutable reference to it even though we also have a mutable
|
||||
// reference to the Subs as a whole. This prevents a clone of the content, which turns out
|
||||
// to be quite expensive.
|
||||
let content = {
|
||||
let ptr = &desc.content as *const _;
|
||||
let ptr = subs.get_content_without_compacting(var) as *const _;
|
||||
unsafe { &*ptr }
|
||||
};
|
||||
|
||||
// Mark the variable as visited before adjusting content, as it may be cyclic.
|
||||
desc.mark = visit_mark;
|
||||
subs.set_mark(var, visit_mark);
|
||||
|
||||
let max_rank = adjust_rank_content(subs, young_mark, visit_mark, group_rank, content);
|
||||
|
||||
|
@ -2646,8 +2640,8 @@ fn adjust_rank(
|
|||
let min_rank = group_rank.min(desc_rank);
|
||||
|
||||
// TODO from elm-compiler: how can min_rank ever be group_rank?
|
||||
desc.rank = min_rank;
|
||||
desc.mark = visit_mark;
|
||||
subs.set_rank(var, min_rank);
|
||||
subs.set_mark(var, visit_mark);
|
||||
|
||||
min_rank
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue