use multiarraylist more optimally in mach.Objects
This commit is contained in:
parent
ab143504ab
commit
eb12b0f476
1 changed files with 3 additions and 10 deletions
|
|
@ -226,10 +226,7 @@ pub fn Objects(options: ObjectsOptions, comptime T: type) type {
|
||||||
const data = &objs.internal.data;
|
const data = &objs.internal.data;
|
||||||
const unpacked = objs.validateAndUnpack(id, "setRaw");
|
const unpacked = objs.validateAndUnpack(id, "setRaw");
|
||||||
|
|
||||||
var current = data.get(unpacked.index);
|
data.items(field_name)[unpacked.index] = value;
|
||||||
@field(current, @tagName(field_name)) = value;
|
|
||||||
|
|
||||||
data.set(unpacked.index, current);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets a single field of the given object to the given value.
|
/// Sets a single field of the given object to the given value.
|
||||||
|
|
@ -240,10 +237,7 @@ pub fn Objects(options: ObjectsOptions, comptime T: type) type {
|
||||||
const data = &objs.internal.data;
|
const data = &objs.internal.data;
|
||||||
const unpacked = objs.validateAndUnpack(id, "set");
|
const unpacked = objs.validateAndUnpack(id, "set");
|
||||||
|
|
||||||
var current = data.get(unpacked.index);
|
data.items(field_name)[unpacked.index] = value;
|
||||||
@field(current, @tagName(field_name)) = value;
|
|
||||||
|
|
||||||
data.set(unpacked.index, current);
|
|
||||||
|
|
||||||
if (options.track_fields)
|
if (options.track_fields)
|
||||||
if (std.meta.fieldIndex(T, @tagName(field_name))) |field_index|
|
if (std.meta.fieldIndex(T, @tagName(field_name))) |field_index|
|
||||||
|
|
@ -256,8 +250,7 @@ pub fn Objects(options: ObjectsOptions, comptime T: type) type {
|
||||||
const data = &objs.internal.data;
|
const data = &objs.internal.data;
|
||||||
|
|
||||||
const unpacked = objs.validateAndUnpack(id, "get");
|
const unpacked = objs.validateAndUnpack(id, "get");
|
||||||
const d = data.get(unpacked.index);
|
return data.items(field_name)[unpacked.index];
|
||||||
return @field(d, @tagName(field_name));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get all fields.
|
/// Get all fields.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue