mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-03 19:58:18 +00:00
Split ListLen into ListLenU64 and ListLenUsize
The usize one gets used internally for things like pattern matches. This is both more efficient (means they don't have to do unnecessary casts) and also less error-prone due to e.g. comparing length to capacity, which is usize.
This commit is contained in:
parent
a15cc0589c
commit
ada83561e5
17 changed files with 88 additions and 48 deletions
|
@ -611,7 +611,7 @@ pub(crate) fn run_low_level<'a, 'ctx>(
|
|||
bitcode::STR_WITH_CAPACITY,
|
||||
)
|
||||
}
|
||||
ListLen => {
|
||||
ListLenU64 => {
|
||||
// List.len : List * -> U64
|
||||
arguments!(list);
|
||||
|
||||
|
@ -622,6 +622,12 @@ pub(crate) fn run_low_level<'a, 'ctx>(
|
|||
.new_build_int_cast(len_usize, env.context.i64_type(), "usize_to_u64")
|
||||
.into()
|
||||
}
|
||||
ListLenUsize => {
|
||||
// List.lenUsize : List * -> usize # used internally, not exposed
|
||||
arguments!(list);
|
||||
|
||||
list_len_usize(env.builder, list.into_struct_value()).into()
|
||||
}
|
||||
ListGetCapacity => {
|
||||
// List.capacity: List a -> U64
|
||||
arguments!(list);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue