mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-03 11:52:19 +00:00
Use list element width for List.withCapacity
This commit is contained in:
parent
f80edb6ed6
commit
a1e2c3f64b
2 changed files with 12 additions and 2 deletions
|
@ -1269,6 +1269,7 @@ impl<
|
|||
dst: &Symbol,
|
||||
capacity: Symbol,
|
||||
capacity_layout: InLayout<'a>,
|
||||
element_layout: InLayout<'a>,
|
||||
ret_layout: &InLayout<'a>,
|
||||
) {
|
||||
// List alignment argument (u32).
|
||||
|
@ -1282,7 +1283,7 @@ impl<
|
|||
|
||||
// Load element_width argument (usize).
|
||||
let u64_layout = Layout::U64;
|
||||
let element_width = self.layout_interner.stack_size(*ret_layout);
|
||||
let element_width = self.layout_interner.stack_size(element_layout);
|
||||
self.load_literal(
|
||||
&Symbol::DEV_TMP2,
|
||||
&u64_layout,
|
||||
|
|
|
@ -21,6 +21,7 @@ use roc_mono::layout::{
|
|||
Builtin, InLayout, Layout, LayoutId, LayoutIds, LayoutInterner, STLayoutInterner, TagIdIntType,
|
||||
UnionLayout,
|
||||
};
|
||||
use roc_mono::list_element_layout;
|
||||
|
||||
mod generic64;
|
||||
mod object_builder;
|
||||
|
@ -685,7 +686,14 @@ trait Backend<'a> {
|
|||
args.len(),
|
||||
"ListWithCapacity: expected to have exactly one argument"
|
||||
);
|
||||
self.build_list_with_capacity(sym, args[0], arg_layouts[0], ret_layout)
|
||||
let element_layout = list_element_layout!(self.interner(), *ret_layout);
|
||||
self.build_list_with_capacity(
|
||||
sym,
|
||||
args[0],
|
||||
arg_layouts[0],
|
||||
element_layout,
|
||||
ret_layout,
|
||||
)
|
||||
}
|
||||
LowLevel::ListReserve => {
|
||||
debug_assert_eq!(
|
||||
|
@ -948,6 +956,7 @@ trait Backend<'a> {
|
|||
dst: &Symbol,
|
||||
capacity: Symbol,
|
||||
capacity_layout: InLayout<'a>,
|
||||
element_layout: InLayout<'a>,
|
||||
ret_layout: &InLayout<'a>,
|
||||
);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue