mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 06:14:46 +00:00
use set_content_unchecked; replace modify with a single set
This commit is contained in:
parent
f1e1c45f2f
commit
8c44661bc2
2 changed files with 16 additions and 21 deletions
|
@ -3028,13 +3028,7 @@ fn deep_copy_var_in(
|
||||||
// we have tracked all visited variables, and can now traverse them
|
// we have tracked all visited variables, and can now traverse them
|
||||||
// in one go (without looking at the UnificationTable) and clear the copy field
|
// in one go (without looking at the UnificationTable) and clear the copy field
|
||||||
for var in visited {
|
for var in visited {
|
||||||
subs.modify(var, |descriptor| {
|
subs.set_copy_unchecked(var, OptVariable::NONE);
|
||||||
if descriptor.copy.is_some() {
|
|
||||||
descriptor.rank = Rank::NONE;
|
|
||||||
descriptor.mark = Mark::NONE;
|
|
||||||
descriptor.copy = OptVariable::NONE;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
copy
|
copy
|
||||||
|
@ -3198,7 +3192,7 @@ fn deep_copy_var_help(
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
subs.set(copy, make_descriptor(Structure(new_flat_type)));
|
subs.set_content_unchecked(copy, Structure(new_flat_type));
|
||||||
|
|
||||||
copy
|
copy
|
||||||
}
|
}
|
||||||
|
@ -3211,25 +3205,24 @@ fn deep_copy_var_help(
|
||||||
} => {
|
} => {
|
||||||
let new_structure = deep_copy_var_help(subs, max_rank, pools, visited, structure);
|
let new_structure = deep_copy_var_help(subs, max_rank, pools, visited, structure);
|
||||||
|
|
||||||
subs.set(
|
let content = RecursionVar {
|
||||||
copy,
|
|
||||||
make_descriptor(RecursionVar {
|
|
||||||
opt_name,
|
opt_name,
|
||||||
structure: new_structure,
|
structure: new_structure,
|
||||||
}),
|
};
|
||||||
);
|
|
||||||
|
subs.set_content_unchecked(copy, content);
|
||||||
|
|
||||||
copy
|
copy
|
||||||
}
|
}
|
||||||
|
|
||||||
RigidVar(name) => {
|
RigidVar(name) => {
|
||||||
subs.set(copy, make_descriptor(FlexVar(Some(name))));
|
subs.set_content_unchecked(copy, FlexVar(Some(name)));
|
||||||
|
|
||||||
copy
|
copy
|
||||||
}
|
}
|
||||||
|
|
||||||
RigidAbleVar(name, ability) => {
|
RigidAbleVar(name, ability) => {
|
||||||
subs.set(copy, make_descriptor(FlexAbleVar(Some(name), ability)));
|
subs.set_content_unchecked(copy, FlexAbleVar(Some(name), ability));
|
||||||
|
|
||||||
copy
|
copy
|
||||||
}
|
}
|
||||||
|
@ -3247,7 +3240,7 @@ fn deep_copy_var_help(
|
||||||
deep_copy_var_help(subs, max_rank, pools, visited, real_type_var);
|
deep_copy_var_help(subs, max_rank, pools, visited, real_type_var);
|
||||||
let new_content = Alias(symbol, new_arguments, new_real_type_var, kind);
|
let new_content = Alias(symbol, new_arguments, new_real_type_var, kind);
|
||||||
|
|
||||||
subs.set(copy, make_descriptor(new_content));
|
subs.set_content_unchecked(copy, new_content);
|
||||||
|
|
||||||
copy
|
copy
|
||||||
}
|
}
|
||||||
|
@ -3259,7 +3252,7 @@ fn deep_copy_var_help(
|
||||||
|
|
||||||
let new_content = RangedNumber(new_type_var, new_variables);
|
let new_content = RangedNumber(new_type_var, new_variables);
|
||||||
|
|
||||||
subs.set(copy, make_descriptor(new_content));
|
subs.set_content_unchecked(copy, new_content);
|
||||||
|
|
||||||
copy
|
copy
|
||||||
}
|
}
|
||||||
|
|
|
@ -1720,11 +1720,13 @@ impl Subs {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_content(&mut self, key: Variable, content: Content) {
|
pub fn set_content(&mut self, key: Variable, content: Content) {
|
||||||
// let l_key = self.utable.inlined_get_root_key(key);
|
|
||||||
|
|
||||||
self.utable.set_content(key, content);
|
self.utable.set_content(key, content);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn set_content_unchecked(&mut self, key: Variable, content: Content) {
|
||||||
|
self.utable.set_content_unchecked(key, content);
|
||||||
|
}
|
||||||
|
|
||||||
pub fn modify<F, T>(&mut self, key: Variable, mapper: F) -> T
|
pub fn modify<F, T>(&mut self, key: Variable, mapper: F) -> T
|
||||||
where
|
where
|
||||||
F: FnOnce(&mut Descriptor) -> T,
|
F: FnOnce(&mut Descriptor) -> T,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue