mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-02 11:22:19 +00:00
fix bug where we don't decrement elements if the list is non-unique
This commit is contained in:
parent
a955a4937c
commit
2a6c82c937
1 changed files with 11 additions and 11 deletions
|
@ -606,19 +606,19 @@ pub fn listSublist(
|
|||
) callconv(.C) RocList {
|
||||
const size = list.len();
|
||||
if (len == 0 or start >= size) {
|
||||
if (list.isUnique()) {
|
||||
// Decrement the reference counts of all elements.
|
||||
if (list.bytes) |source_ptr| {
|
||||
var i: usize = 0;
|
||||
while (i < size) : (i += 1) {
|
||||
const element = source_ptr + i * element_width;
|
||||
dec(element);
|
||||
}
|
||||
var output = list;
|
||||
output.length = 0;
|
||||
return output;
|
||||
// Decrement the reference counts of all elements.
|
||||
if (list.bytes) |source_ptr| {
|
||||
var i: usize = 0;
|
||||
while (i < size) : (i += 1) {
|
||||
const element = source_ptr + i * element_width;
|
||||
dec(element);
|
||||
}
|
||||
}
|
||||
if (list.isUnique()) {
|
||||
var output = list;
|
||||
output.length = 0;
|
||||
return output;
|
||||
}
|
||||
list.decref(alignment);
|
||||
return RocList.empty();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue