mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 07:08:48 +00:00
@@ -898,8 +898,7 @@ bitset_to_enum_slice_with_buffer :: proc(buf: []$E, bs: $T) -> (slice: []E) wher
|
|||||||
// sl := slice.bitset_to_enum_slice(bs)
|
// sl := slice.bitset_to_enum_slice(bs)
|
||||||
@(require_results)
|
@(require_results)
|
||||||
bitset_to_enum_slice_with_make :: proc(bs: $T, $E: typeid, allocator := context.allocator) -> (slice: []E) where intrinsics.type_is_enum(E), intrinsics.type_bit_set_elem_type(T) == E {
|
bitset_to_enum_slice_with_make :: proc(bs: $T, $E: typeid, allocator := context.allocator) -> (slice: []E) where intrinsics.type_is_enum(E), intrinsics.type_bit_set_elem_type(T) == E {
|
||||||
ones := intrinsics.count_ones(transmute(E)bs)
|
buf := make([]E, card(bs), allocator)
|
||||||
buf := make([]E, int(ones), allocator)
|
|
||||||
return bitset_to_enum_slice(buf, bs)
|
return bitset_to_enum_slice(buf, bs)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user