mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-29 06:44:46 +00:00
Switched order of checking layout and list length for list reverse implementation
This commit is contained in:
parent
fdf11689b6
commit
1221ef3c76
1 changed files with 36 additions and 36 deletions
|
@ -1649,6 +1649,8 @@ fn run_low_level<'a, 'ctx, 'env>(
|
||||||
|
|
||||||
let (list, list_layout) = &args[0];
|
let (list, list_layout) = &args[0];
|
||||||
|
|
||||||
|
match list_layout {
|
||||||
|
Layout::Builtin(Builtin::List(elem_layout)) => {
|
||||||
let wrapper_struct =
|
let wrapper_struct =
|
||||||
build_expr(env, layout_ids, scope, parent, list).into_struct_value();
|
build_expr(env, layout_ids, scope, parent, list).into_struct_value();
|
||||||
|
|
||||||
|
@ -1668,8 +1670,6 @@ fn run_low_level<'a, 'ctx, 'env>(
|
||||||
);
|
);
|
||||||
|
|
||||||
let build_then = || {
|
let build_then = || {
|
||||||
match list_layout {
|
|
||||||
Layout::Builtin(Builtin::List(elem_layout)) => {
|
|
||||||
// Allocate space for the new array that we'll copy into.
|
// Allocate space for the new array that we'll copy into.
|
||||||
let elem_type =
|
let elem_type =
|
||||||
basic_type_from_layout(env.arena, ctx, elem_layout, env.ptr_bytes);
|
basic_type_from_layout(env.arena, ctx, elem_layout, env.ptr_bytes);
|
||||||
|
@ -1785,12 +1785,6 @@ fn run_low_level<'a, 'ctx, 'env>(
|
||||||
collection(ctx, ptr_bytes),
|
collection(ctx, ptr_bytes),
|
||||||
"cast_collection",
|
"cast_collection",
|
||||||
)
|
)
|
||||||
}
|
|
||||||
Layout::Builtin(Builtin::EmptyList) => empty_list(env),
|
|
||||||
_ => {
|
|
||||||
unreachable!("Invalid List layout for List.get: {:?}", list_layout);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let build_else = || empty_list(env);
|
let build_else = || empty_list(env);
|
||||||
|
@ -1806,6 +1800,12 @@ fn run_low_level<'a, 'ctx, 'env>(
|
||||||
BasicTypeEnum::StructType(struct_type),
|
BasicTypeEnum::StructType(struct_type),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Layout::Builtin(Builtin::EmptyList) => empty_list(env),
|
||||||
|
_ => {
|
||||||
|
unreachable!("Invalid List layout for List.reverse {:?}", list_layout);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
ListPush => {
|
ListPush => {
|
||||||
// List.push List elem, elem -> List elem
|
// List.push List elem, elem -> List elem
|
||||||
debug_assert_eq!(args.len(), 2);
|
debug_assert_eq!(args.len(), 2);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue