mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-02 11:22:19 +00:00
Put back a bunch of the push_new etc. calls
This commit is contained in:
parent
49d1786f6c
commit
178bc469e6
3 changed files with 94 additions and 108 deletions
|
@ -1787,11 +1787,7 @@ fn unify_unspecialized_lambdas<M: MetaCollector>(
|
|||
);
|
||||
|
||||
Ok((
|
||||
{
|
||||
let start = env.unspecialized_lambda_sets.len() as u32;
|
||||
env.unspecialized_lambda_sets.extend(merged_uls);
|
||||
SubsSlice::new(start, env.unspecialized_lambda_sets.len() as u16)
|
||||
},
|
||||
SubsSlice::extend_new(&mut env.unspecialized_lambda_sets, merged_uls),
|
||||
whole_outcome,
|
||||
))
|
||||
}
|
||||
|
@ -3246,7 +3242,7 @@ fn unify_flat_type<M: MetaCollector>(
|
|||
let mut outcome = unify_zip_slices(env, pool, *l_args, *r_args, ctx.mode);
|
||||
|
||||
if outcome.mismatches.is_empty() {
|
||||
let chosen_args = env.reserve_into_vars(l_args.len());
|
||||
let chosen_args = SubsSlice::reserve_into_subs(env, l_args.len());
|
||||
for ((store, var1), var2) in chosen_args
|
||||
.into_iter()
|
||||
.zip(l_args.into_iter())
|
||||
|
@ -3329,23 +3325,19 @@ fn unify_flat_type<M: MetaCollector>(
|
|||
*ext2,
|
||||
),
|
||||
(TagUnion(tags1, ext1), FunctionOrTagUnion(tag_names, _, ext2)) => {
|
||||
let empty_tag_var_slices = {
|
||||
let start = env.variable_slices.len() as u32;
|
||||
env.variable_slices
|
||||
.extend(std::iter::repeat(SubsSlice::empty()).take(tag_names.len()));
|
||||
SubsSlice::new(start, env.variable_slices.len() as u16)
|
||||
};
|
||||
let empty_tag_var_slices = SubsSlice::extend_new(
|
||||
&mut env.variable_slices,
|
||||
std::iter::repeat(Default::default()).take(tag_names.len()),
|
||||
);
|
||||
let tags2 = UnionTags::from_slices(*tag_names, empty_tag_var_slices);
|
||||
|
||||
unify_tag_unions(env, pool, ctx, *tags1, *ext1, tags2, *ext2)
|
||||
}
|
||||
(FunctionOrTagUnion(tag_names, _, ext1), TagUnion(tags2, ext2)) => {
|
||||
let empty_tag_var_slices = {
|
||||
let start = env.variable_slices.len() as u32;
|
||||
env.variable_slices
|
||||
.extend(std::iter::repeat(SubsSlice::empty()).take(tag_names.len()));
|
||||
SubsSlice::new(start, env.variable_slices.len() as u16)
|
||||
};
|
||||
let empty_tag_var_slices = SubsSlice::extend_new(
|
||||
&mut env.variable_slices,
|
||||
std::iter::repeat(Default::default()).take(tag_names.len()),
|
||||
);
|
||||
let tags1 = UnionTags::from_slices(*tag_names, empty_tag_var_slices);
|
||||
|
||||
unify_tag_unions(env, pool, ctx, tags1, *ext1, *tags2, *ext2)
|
||||
|
@ -3355,12 +3347,10 @@ fn unify_flat_type<M: MetaCollector>(
|
|||
// this never happens in type-correct programs, but may happen if there is a type error
|
||||
debug_assert!(is_recursion_var(env, *recursion_var));
|
||||
|
||||
let empty_tag_var_slices = {
|
||||
let start = env.variable_slices.len() as u32;
|
||||
env.variable_slices
|
||||
.extend(std::iter::repeat(SubsSlice::empty()).take(tag_names.len()));
|
||||
SubsSlice::new(start, env.variable_slices.len() as u16)
|
||||
};
|
||||
let empty_tag_var_slices = SubsSlice::extend_new(
|
||||
&mut env.variable_slices,
|
||||
std::iter::repeat(Default::default()).take(tag_names.len()),
|
||||
);
|
||||
let tags2 = UnionTags::from_slices(*tag_names, empty_tag_var_slices);
|
||||
|
||||
unify_tag_unions(env, pool, ctx, *tags1, *ext1, tags2, *ext2)
|
||||
|
@ -3369,12 +3359,10 @@ fn unify_flat_type<M: MetaCollector>(
|
|||
(FunctionOrTagUnion(tag_names, _, ext1), RecursiveTagUnion(recursion_var, tags2, ext2)) => {
|
||||
debug_assert!(is_recursion_var(env, *recursion_var));
|
||||
|
||||
let empty_tag_var_slices = {
|
||||
let start = env.variable_slices.len() as u32;
|
||||
env.variable_slices
|
||||
.extend(std::iter::repeat(SubsSlice::empty()).take(tag_names.len()));
|
||||
SubsSlice::new(start, env.variable_slices.len() as u16)
|
||||
};
|
||||
let empty_tag_var_slices = SubsSlice::extend_new(
|
||||
&mut env.variable_slices,
|
||||
std::iter::repeat(Default::default()).take(tag_names.len()),
|
||||
);
|
||||
let tags1 = UnionTags::from_slices(*tag_names, empty_tag_var_slices);
|
||||
|
||||
unify_tag_unions(env, pool, ctx, tags1, *ext1, *tags2, *ext2)
|
||||
|
@ -3599,7 +3587,7 @@ pub fn merged_ability_slices(
|
|||
let merged = merge_sorted_keys(left.iter().copied(), right.iter().copied());
|
||||
|
||||
// TODO: check if there's an existing run in subs rather than re-inserting
|
||||
subs.extend_symbol_names(merged)
|
||||
SubsSlice::extend_new(&mut subs.symbol_names, merged)
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
|
@ -3900,13 +3888,11 @@ fn unify_function_or_tag_union_and_func<M: MetaCollector>(
|
|||
|
||||
{
|
||||
let lambda_names = env.get_subs_slice(tag_fn_lambdas).to_vec();
|
||||
let new_lambda_names = env.extend_symbol_names(lambda_names);
|
||||
let empty_captures_slices = {
|
||||
let start = env.variable_slices.len() as u32;
|
||||
env.variable_slices
|
||||
.extend(std::iter::repeat(SubsSlice::empty()).take(new_lambda_names.len()));
|
||||
SubsSlice::new(start, env.variable_slices.len() as u16)
|
||||
};
|
||||
let new_lambda_names = SubsSlice::extend_new(&mut env.symbol_names, lambda_names);
|
||||
let empty_captures_slices = SubsSlice::extend_new(
|
||||
&mut env.variable_slices,
|
||||
std::iter::repeat(Default::default()).take(new_lambda_names.len()),
|
||||
);
|
||||
let union_tags = UnionLambdas::from_slices(new_lambda_names, empty_captures_slices);
|
||||
|
||||
let ambient_function_var = if left { ctx.first } else { ctx.second };
|
||||
|
@ -3969,7 +3955,7 @@ fn unify_two_function_or_tag_unions<M: MetaCollector>(
|
|||
.collect();
|
||||
all_tags.sort();
|
||||
all_tags.dedup();
|
||||
env.extend_tag_names(all_tags)
|
||||
SubsSlice::extend_new(&mut env.tag_names, all_tags)
|
||||
};
|
||||
let merged_lambdas = {
|
||||
let mut all_lambdas: Vec<_> = (env.get_subs_slice(tag_symbols_1).iter())
|
||||
|
@ -3978,7 +3964,7 @@ fn unify_two_function_or_tag_unions<M: MetaCollector>(
|
|||
.collect();
|
||||
all_lambdas.sort();
|
||||
all_lambdas.dedup();
|
||||
env.extend_symbol_names(all_lambdas)
|
||||
SubsSlice::extend_new(&mut env.symbol_names, all_lambdas)
|
||||
};
|
||||
|
||||
let mut outcome = unify_pool(env, pool, ext1.var(), ext2.var(), ctx.mode);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue