remove match cause build_eq can tell if it can't compare the BasicEnumValues

This commit is contained in:
lrosa007 2020-11-05 08:54:12 -05:00
parent 4f5237fcd8
commit d880293afa

View file

@ -863,15 +863,12 @@ pub fn list_contains_help<'a, 'ctx, 'env>(
elem: BasicValueEnum<'ctx>,
elem_layout: &Layout<'a>,
) -> BasicValueEnum<'ctx> {
match (elem, elem_layout) {
(BasicValueEnum::IntValue(_), _) => {
let builder = env.builder;
let ctx = env.context;
let bool_alloca = builder.build_alloca(ctx.bool_type(), "bool_alloca");
let index_alloca = builder.build_alloca(ctx.i64_type(), "index_alloca");
let next_free_index_alloca =
builder.build_alloca(ctx.i64_type(), "next_free_index_alloca");
let next_free_index_alloca = builder.build_alloca(ctx.i64_type(), "next_free_index_alloca");
builder.build_store(bool_alloca, ctx.bool_type().const_zero());
builder.build_store(index_alloca, ctx.i64_type().const_zero());
@ -892,8 +889,7 @@ pub fn list_contains_help<'a, 'ctx, 'env>(
// loop body
builder.position_at_end(body_bb);
let current_elem_ptr =
unsafe { builder.build_in_bounds_gep(source_ptr, &[index], "elem_ptr") };
let current_elem_ptr = unsafe { builder.build_in_bounds_gep(source_ptr, &[index], "elem_ptr") };
let current_elem = builder.build_load(current_elem_ptr, "load_elem");
@ -924,12 +920,6 @@ pub fn list_contains_help<'a, 'ctx, 'env>(
builder.build_load(bool_alloca, "answer")
}
_ => unreachable!(
"Invalid element basic value enum or layout for List.contains : {:?}",
(elem, elem_layout)
),
}
}
/// List.keepIf : List elem, (elem -> Bool) -> List elem
pub fn list_keep_if<'a, 'ctx, 'env>(