mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-02 16:21:11 +00:00
Refinements from @folkertdev review
This commit is contained in:
parent
3692b38447
commit
e7b506646b
2 changed files with 8 additions and 18 deletions
|
@ -1602,9 +1602,8 @@ fn layout_from_flat_type<'a>(
|
|||
// That means none of the optimizations for enums or single tag tag unions apply
|
||||
|
||||
let rec_var = subs.get_root_key_without_compacting(rec_var);
|
||||
let mut tag_layouts = Vec::with_capacity_in(tags.tags.len(), arena);
|
||||
|
||||
let tags_vec = cheap_sort_tags(&tags);
|
||||
let tags_vec = tags.tags;
|
||||
let mut tag_layouts = Vec::with_capacity_in(tags_vec.len(), arena);
|
||||
|
||||
let mut nullable = None;
|
||||
|
||||
|
@ -2323,10 +2322,6 @@ pub fn union_sorted_tags_help<'a>(
|
|||
}
|
||||
}
|
||||
|
||||
fn cheap_sort_tags<'a>(tags: &'a UnsortedUnionTags) -> &'a [(&'a TagName, &'a [Variable])] {
|
||||
&tags.tags
|
||||
}
|
||||
|
||||
fn layout_from_newtype<'a>(
|
||||
arena: &'a Bump,
|
||||
tags: &UnsortedUnionTags,
|
||||
|
@ -2376,7 +2371,7 @@ fn layout_from_tag_union<'a>(
|
|||
return layout_from_newtype(arena, tags, subs, ptr_bytes);
|
||||
}
|
||||
|
||||
let tags_vec = cheap_sort_tags(tags);
|
||||
let tags_vec = &tags.tags;
|
||||
|
||||
match tags_vec.get(0) {
|
||||
Some((tag_name, arguments)) if *tag_name == &TagName::Private(Symbol::NUM_AT_NUM) => {
|
||||
|
|
|
@ -830,10 +830,7 @@ fn integer_type(
|
|||
) {
|
||||
// define the type Signed64 (which is an alias for [ @Signed64 ])
|
||||
{
|
||||
let tags = UnionTags::insert_into_subs::<Variable, _, _>(
|
||||
subs,
|
||||
[(TagName::Private(num_at_signed64), [])],
|
||||
);
|
||||
let tags = UnionTags::insert_into_subs(subs, [(TagName::Private(num_at_signed64), [])]);
|
||||
|
||||
subs.set_content(at_signed64, {
|
||||
Content::Structure(FlatType::TagUnion(tags, Variable::EMPTY_TAG_UNION))
|
||||
|
@ -1085,7 +1082,7 @@ impl Subs {
|
|||
Content::Structure(FlatType::EmptyTagUnion),
|
||||
);
|
||||
|
||||
let bool_union_tags = UnionTags::insert_into_subs::<Variable, _, _>(
|
||||
let bool_union_tags = UnionTags::insert_into_subs(
|
||||
&mut subs,
|
||||
[
|
||||
(TagName::Global("False".into()), []),
|
||||
|
@ -1727,11 +1724,10 @@ impl UnionTags {
|
|||
pub fn compare<T>(x: &(TagName, T), y: &(TagName, T)) -> std::cmp::Ordering {
|
||||
first(x, y)
|
||||
}
|
||||
pub fn insert_into_subs<V, I, I2>(subs: &mut Subs, input: I) -> Self
|
||||
pub fn insert_into_subs<I, I2>(subs: &mut Subs, input: I) -> Self
|
||||
where
|
||||
V: Into<Variable>,
|
||||
I: IntoIterator<Item = (TagName, I2)>,
|
||||
I2: IntoIterator<Item = V>,
|
||||
I2: IntoIterator<Item = Variable>,
|
||||
{
|
||||
let tag_names_start = subs.tag_names.len() as u32;
|
||||
let variables_start = subs.variable_slices.len() as u32;
|
||||
|
@ -1744,8 +1740,7 @@ impl UnionTags {
|
|||
|
||||
let mut length = 0;
|
||||
for (k, v) in it {
|
||||
let variables =
|
||||
VariableSubsSlice::insert_into_subs(subs, v.into_iter().map(|v| v.into()));
|
||||
let variables = VariableSubsSlice::insert_into_subs(subs, v.into_iter());
|
||||
|
||||
subs.tag_names.push(k);
|
||||
subs.variable_slices.push(variables);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue