diff options
| author | Laytan Laats <laytanlaats@hotmail.com> | 2024-10-26 13:50:28 +0200 |
|---|---|---|
| committer | Laytan Laats <laytanlaats@hotmail.com> | 2024-10-26 13:50:28 +0200 |
| commit | 10c2f8dbeb2126419bfdaadb3d6e21dbbeca0633 (patch) | |
| tree | df668632c34440431201f7c7406bbe9e80e00064 /base | |
| parent | 831558a7c24cc83da0c1a56c5de2d74464e0ce3a (diff) | |
math/rand: add `choice_bit_set`
Diffstat (limited to 'base')
| -rw-r--r-- | base/runtime/core_builtin.odin | 14 |
1 files changed, 1 insertions, 13 deletions
diff --git a/base/runtime/core_builtin.odin b/base/runtime/core_builtin.odin index 3dad2fdbc..8b7a5004a 100644 --- a/base/runtime/core_builtin.odin +++ b/base/runtime/core_builtin.odin @@ -939,19 +939,7 @@ map_upsert :: proc(m: ^$T/map[$K]$V, key: K, value: V, loc := #caller_location) @builtin card :: proc "contextless" (s: $S/bit_set[$E; $U]) -> int { - when size_of(S) == 1 { - return int(intrinsics.count_ones(transmute(u8)s)) - } else when size_of(S) == 2 { - return int(intrinsics.count_ones(transmute(u16)s)) - } else when size_of(S) == 4 { - return int(intrinsics.count_ones(transmute(u32)s)) - } else when size_of(S) == 8 { - return int(intrinsics.count_ones(transmute(u64)s)) - } else when size_of(S) == 16 { - return int(intrinsics.count_ones(transmute(u128)s)) - } else { - #panic("Unhandled card bit_set size") - } + return int(intrinsics.count_ones(transmute(intrinsics.type_bit_set_underlying_type(S))s)) } |