Skip to content

Commit

Permalink
use multiarraylist more optimally in mach.Objects
Browse files Browse the repository at this point in the history
  • Loading branch information
xdBronch committed Jan 8, 2025
1 parent 1d01c91 commit 03dc558
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions src/module.zig
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,7 @@ pub fn Objects(options: ObjectsOptions, comptime T: type) type {
const data = &objs.internal.data;
const unpacked = objs.validateAndUnpack(id, "setRaw");

var current = data.get(unpacked.index);
@field(current, @tagName(field_name)) = value;

data.set(unpacked.index, current);
data.items(field_name)[unpacked.index] = value;
}

/// Sets a single field of the given object to the given value.
Expand All @@ -240,10 +237,7 @@ pub fn Objects(options: ObjectsOptions, comptime T: type) type {
const data = &objs.internal.data;
const unpacked = objs.validateAndUnpack(id, "set");

var current = data.get(unpacked.index);
@field(current, @tagName(field_name)) = value;

data.set(unpacked.index, current);
data.items(field_name)[unpacked.index] = value;

if (options.track_fields)
if (std.meta.fieldIndex(T, @tagName(field_name))) |field_index|
Expand All @@ -256,8 +250,7 @@ pub fn Objects(options: ObjectsOptions, comptime T: type) type {
const data = &objs.internal.data;

const unpacked = objs.validateAndUnpack(id, "get");
const d = data.get(unpacked.index);
return @field(d, @tagName(field_name));
return data.items(field_name)[unpacked.index];
}

/// Get all fields.
Expand Down

0 comments on commit 03dc558

Please sign in to comment.