clone structs and tags if they are copy

This commit is contained in:
Folkert 2022-07-23 00:15:38 +02:00
parent d4feaf871b
commit 984000095f
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C

View file

@ -144,27 +144,27 @@ fn build_clone<'a, 'ctx, 'env>(
build_clone_builtin(env, ptr, offset, value, builtin, when_recursive) build_clone_builtin(env, ptr, offset, value, builtin, when_recursive)
} }
/* Layout::Struct {
Layout::Struct { field_layouts, .. } => build_struct_eq( field_layouts: _, ..
env, } => {
layout_ids, if layout.safe_to_memcpy() {
field_layouts, build_copy(env, ptr, offset, value)
when_recursive, } else {
lhs_val.into_struct_value(), todo!()
rhs_val.into_struct_value(), }
), }
Layout::LambdaSet(_) => unreachable!("cannot compare closures"), Layout::LambdaSet(_) => unreachable!("cannot compare closures"),
Layout::Union(union_layout) => build_tag_eq( Layout::Union(_union_layout) => {
env, if layout.safe_to_memcpy() {
layout_ids, build_copy(env, ptr, offset, value)
when_recursive, } else {
union_layout, todo!()
lhs_val, }
rhs_val, }
),
/*
Layout::Boxed(inner_layout) => build_box_eq( Layout::Boxed(inner_layout) => build_box_eq(
env, env,
layout_ids, layout_ids,