deal with zero element_width

That being said, this only affects wasm.
So wasm probably should be handling zero element lists in a smarter way.
This commit is contained in:
Brendan Hansknecht 2022-10-07 17:58:48 -07:00
parent f9c87d9190
commit eca4682787
No known key found for this signature in database
GPG key ID: 0EA784685083E75B

View file

@ -150,7 +150,12 @@ pub const RocList = extern struct {
element_width: usize,
) usize {
var new_capacity: usize = 0;
if (old_capacity == 0) {
// TODO: I think this shouldn't be done here.
// We should have a smarter way to deal with this that doesn't lead
// to allocating a refcount for zero width elements.
if (element_width == 0) {
return requested_length;
} else if (old_capacity == 0) {
new_capacity = 64 / element_width;
} else if (old_capacity < 4096 / element_width) {
new_capacity = old_capacity * 2;