use capacity instead of length in list deinit

This commit is contained in:
Folkert 2023-01-16 21:26:35 +01:00
parent b8a6e05ed9
commit 4e5b106f98
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C
3 changed files with 40 additions and 9 deletions

View file

@ -324,6 +324,10 @@ pub const RocStr = extern struct {
}
fn refcountMachine(self: RocStr) usize {
if (self.getCapacity() == 0 or self.isSmallStr()) {
return utils.REFCOUNT_ONE;
}
const ptr: [*]usize = @ptrCast([*]usize, @alignCast(@alignOf(usize), self.str_bytes));
return (ptr - 1)[0];
}