mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-01 07:41:12 +00:00
move check out of main loop
This commit is contained in:
parent
690f3ee5c9
commit
cb8de4ac04
1 changed files with 16 additions and 4 deletions
|
@ -911,6 +911,21 @@ fn build_rec_union_help<'a, 'ctx, 'env>(
|
||||||
debug_assert!(arg_val.is_pointer_value());
|
debug_assert!(arg_val.is_pointer_value());
|
||||||
let value_ptr = arg_val.into_pointer_value();
|
let value_ptr = arg_val.into_pointer_value();
|
||||||
|
|
||||||
|
// branches that are not/don't contain anything refcounted
|
||||||
|
// if there is only one branch, we don't need to switch
|
||||||
|
let switch_needed: bool = (|| {
|
||||||
|
for field_layouts in tags.iter() {
|
||||||
|
// if none of the fields are or contain anything refcounted, just move on
|
||||||
|
if !field_layouts
|
||||||
|
.iter()
|
||||||
|
.any(|x| x.is_refcounted() || x.contains_refcounted())
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
})();
|
||||||
|
|
||||||
let ctx = env.context;
|
let ctx = env.context;
|
||||||
let cont_block = ctx.append_basic_block(parent, "cont");
|
let cont_block = ctx.append_basic_block(parent, "cont");
|
||||||
if is_nullable {
|
if is_nullable {
|
||||||
|
@ -941,22 +956,19 @@ fn build_rec_union_help<'a, 'ctx, 'env>(
|
||||||
|
|
||||||
builder.set_current_debug_location(&context, loc);
|
builder.set_current_debug_location(&context, loc);
|
||||||
|
|
||||||
// branches that are not/don't contain anything refcounted
|
|
||||||
let mut switch_needed = false;
|
|
||||||
|
|
||||||
for (tag_id, field_layouts) in tags.iter().enumerate() {
|
for (tag_id, field_layouts) in tags.iter().enumerate() {
|
||||||
// if none of the fields are or contain anything refcounted, just move on
|
// if none of the fields are or contain anything refcounted, just move on
|
||||||
if !field_layouts
|
if !field_layouts
|
||||||
.iter()
|
.iter()
|
||||||
.any(|x| x.is_refcounted() || x.contains_refcounted())
|
.any(|x| x.is_refcounted() || x.contains_refcounted())
|
||||||
{
|
{
|
||||||
switch_needed = true;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
let block = env
|
let block = env
|
||||||
.context
|
.context
|
||||||
.append_basic_block(parent, pick("tag_id_increment", "tag_id_decrement"));
|
.append_basic_block(parent, pick("tag_id_increment", "tag_id_decrement"));
|
||||||
|
|
||||||
env.builder.position_at_end(block);
|
env.builder.position_at_end(block);
|
||||||
|
|
||||||
let wrapper_type = basic_type_from_layout(
|
let wrapper_type = basic_type_from_layout(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue