From 2df22e29f738ab214893c6d2f0e083618d9a232d Mon Sep 17 00:00:00 2001 From: David Mak Date: Mon, 10 Feb 2025 11:18:08 +0800 Subject: [PATCH] [core] codegen: Simplify TupleType::construct --- nac3core/src/codegen/types/tuple.rs | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/nac3core/src/codegen/types/tuple.rs b/nac3core/src/codegen/types/tuple.rs index ea66feb4..3facf5ea 100644 --- a/nac3core/src/codegen/types/tuple.rs +++ b/nac3core/src/codegen/types/tuple.rs @@ -115,15 +115,8 @@ impl<'ctx> TupleType<'ctx> { /// Constructs a [`TupleValue`] from this type by zero-initializing the tuple value. #[must_use] - pub fn construct( - &self, - ctx: &CodeGenContext<'ctx, '_>, - name: Option<&'ctx str>, - ) -> >::Value { - self.map_struct_value( - Self::llvm_type(ctx.ctx, &self.ty.get_field_types()).const_zero(), - name, - ) + pub fn construct(&self, name: Option<&'ctx str>) -> >::Value { + self.map_struct_value(self.as_abi_type().const_zero(), name) } /// Constructs a [`TupleValue`] from `objects`. The resulting tuple preserves the order of @@ -143,7 +136,7 @@ impl<'ctx> TupleType<'ctx> { .enumerate() .all(|(i, v)| { v.get_type() == unsafe { self.type_at_index_unchecked(i as u32) } })); - let mut value = self.construct(ctx, name); + let mut value = self.construct(name); for (i, val) in values.into_iter().enumerate() { value.store_element(ctx, i as u32, val); }