mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-01 07:41:12 +00:00
fix listSublist
bitcode
This commit is contained in:
parent
cdf19e3feb
commit
17398e4f45
1 changed files with 11 additions and 2 deletions
|
@ -887,14 +887,23 @@ pub fn listSublist(
|
||||||
}
|
}
|
||||||
|
|
||||||
const keep_len = std.math.min(len, size - start);
|
const keep_len = std.math.min(len, size - start);
|
||||||
const drop_len = std.math.max(start, 0);
|
const drop_start_len = start;
|
||||||
|
const drop_end_len = size - (start + keep_len);
|
||||||
|
|
||||||
|
// Decrement the reference counts of elements before `start`.
|
||||||
var i: usize = 0;
|
var i: usize = 0;
|
||||||
while (i < drop_len) : (i += 1) {
|
while (i < drop_start_len) : (i += 1) {
|
||||||
const element = source_ptr + i * element_width;
|
const element = source_ptr + i * element_width;
|
||||||
dec(element);
|
dec(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Decrement the reference counts of elements after `start + keep_len`.
|
||||||
|
i = 0;
|
||||||
|
while (i < drop_end_len) : (i += 1) {
|
||||||
|
const element = source_ptr + (start + keep_len + i) * element_width;
|
||||||
|
dec(element);
|
||||||
|
}
|
||||||
|
|
||||||
const output = RocList.allocate(alignment, keep_len, element_width);
|
const output = RocList.allocate(alignment, keep_len, element_width);
|
||||||
const target_ptr = output.bytes orelse unreachable;
|
const target_ptr = output.bytes orelse unreachable;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue