mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-03 19:58:18 +00:00
add List.releaseExcessCapacity builtin
This commit is contained in:
parent
40b50b0091
commit
1319ba4844
13 changed files with 177 additions and 3 deletions
|
@ -183,6 +183,26 @@ pub(crate) fn list_reserve<'a, 'ctx, 'env>(
|
|||
)
|
||||
}
|
||||
|
||||
/// List.releaseExcessCapacity : List elem -> List elem
|
||||
pub(crate) fn list_release_excess_capacity<'a, 'ctx, 'env>(
|
||||
env: &Env<'a, 'ctx, 'env>,
|
||||
layout_interner: &mut STLayoutInterner<'a>,
|
||||
list: BasicValueEnum<'ctx>,
|
||||
element_layout: InLayout<'a>,
|
||||
update_mode: UpdateMode,
|
||||
) -> BasicValueEnum<'ctx> {
|
||||
call_list_bitcode_fn_1(
|
||||
env,
|
||||
list.into_struct_value(),
|
||||
&[
|
||||
env.alignment_intvalue(layout_interner, element_layout),
|
||||
layout_width(env, layout_interner, element_layout),
|
||||
pass_update_mode(env, update_mode),
|
||||
],
|
||||
bitcode::LIST_RELEASE_EXCESS_CAPACITY,
|
||||
)
|
||||
}
|
||||
|
||||
/// List.appendUnsafe : List elem, elem -> List elem
|
||||
pub(crate) fn list_append_unsafe<'a, 'ctx, 'env>(
|
||||
env: &Env<'a, 'ctx, 'env>,
|
||||
|
|
|
@ -29,9 +29,9 @@ use crate::llvm::{
|
|||
},
|
||||
build_list::{
|
||||
list_append_unsafe, list_concat, list_drop_at, list_get_unsafe, list_len, list_map,
|
||||
list_map2, list_map3, list_map4, list_prepend, list_replace_unsafe, list_reserve,
|
||||
list_sort_with, list_sublist, list_swap, list_symbol_to_c_abi, list_with_capacity,
|
||||
pass_update_mode,
|
||||
list_map2, list_map3, list_map4, list_prepend, list_release_excess_capacity,
|
||||
list_replace_unsafe, list_reserve, list_sort_with, list_sublist, list_swap,
|
||||
list_symbol_to_c_abi, list_with_capacity, pass_update_mode,
|
||||
},
|
||||
compare::{generic_eq, generic_neq},
|
||||
convert::{
|
||||
|
@ -707,6 +707,15 @@ pub(crate) fn run_low_level<'a, 'ctx, 'env>(
|
|||
update_mode,
|
||||
)
|
||||
}
|
||||
ListReleaseExcessCapacity => {
|
||||
// List.releaseExcessCapacity: List elem -> List elem
|
||||
debug_assert_eq!(args.len(), 1);
|
||||
|
||||
let (list, list_layout) = load_symbol_and_layout(scope, &args[0]);
|
||||
let element_layout = list_element_layout!(layout_interner, list_layout);
|
||||
|
||||
list_release_excess_capacity(env, layout_interner, list, element_layout, update_mode)
|
||||
}
|
||||
ListSwap => {
|
||||
// List.swap : List elem, Nat, Nat -> List elem
|
||||
debug_assert_eq!(args.len(), 3);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue