mirror of
https://github.com/roc-lang/roc.git
synced 2025-12-23 08:48:03 +00:00
Remove unnecessary noopDecref
This commit is contained in:
parent
90fca6014f
commit
b975934b40
2 changed files with 7 additions and 13 deletions
|
|
@ -28,12 +28,6 @@ const Closure = layout_mod.Closure;
|
|||
const Expr = CIR.Expr;
|
||||
const Ident = base.Ident;
|
||||
|
||||
// RocList.decref always requires a callback for element teardown. When we've
|
||||
// already decref'd the elements ourselves (or they don't need refcounting), we
|
||||
// pass this no-op stub so the list header can clean up without touching the
|
||||
// payload again.
|
||||
fn noopDecref(_: ?*anyopaque, _: ?[*]u8) callconv(.c) void {}
|
||||
|
||||
const StackValue = @This();
|
||||
|
||||
/// Type and memory layout information for the result value
|
||||
|
|
@ -870,7 +864,9 @@ pub fn decref(self: StackValue, layout_cache: *LayoutStore, ops: *RocOps) void {
|
|||
}
|
||||
}
|
||||
}
|
||||
list_value.decref(alignment_u32, element_width, elements_refcounted, null, noopDecref, ops);
|
||||
// We already decreffed all elements above, so pass rcNone to avoid double-decref.
|
||||
// But we still need elements_refcounted=true for correct allocation layout.
|
||||
list_value.decref(alignment_u32, element_width, elements_refcounted, null, &builtins.list.rcNone, ops);
|
||||
return;
|
||||
},
|
||||
.list_of_zst => {
|
||||
|
|
@ -878,7 +874,7 @@ pub fn decref(self: StackValue, layout_cache: *LayoutStore, ops: *RocOps) void {
|
|||
const list_header: *const RocList = @ptrCast(@alignCast(self.ptr.?));
|
||||
const list_value = list_header.*;
|
||||
const alignment_u32: u32 = @intCast(layout_cache.targetUsize().size());
|
||||
list_value.decref(alignment_u32, 0, false, null, noopDecref, ops);
|
||||
list_value.decref(alignment_u32, 0, false, null, &builtins.list.rcNone, ops);
|
||||
return;
|
||||
},
|
||||
.box => {
|
||||
|
|
|
|||
|
|
@ -2231,15 +2231,13 @@ pub const Interpreter = struct {
|
|||
},
|
||||
.list_concat => {
|
||||
// List.concat : List(a), List(a) -> List(a)
|
||||
// Args: List(a), List(a)
|
||||
// Returns: List(a) (concatenated list)
|
||||
std.debug.assert(args.len == 2); // low-level .list_concat expects 2 arguments
|
||||
std.debug.assert(args.len == 2);
|
||||
|
||||
const list_a_arg = args[0];
|
||||
const list_b_arg = args[1];
|
||||
|
||||
std.debug.assert(list_a_arg.ptr != null); // low-level .list_concat expects non-null list pointer
|
||||
std.debug.assert(list_b_arg.ptr != null); // low-level .list_concat expects non-null list pointer
|
||||
std.debug.assert(list_a_arg.ptr != null);
|
||||
std.debug.assert(list_b_arg.ptr != null);
|
||||
|
||||
// Extract element layout from List(a)
|
||||
std.debug.assert(list_a_arg.layout.tag == .list or list_a_arg.layout.tag == .list_of_zst);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue