module: fix anyUpdated; make fields default to updated=true
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
1b7398f580
commit
8f642097e5
1 changed files with 5 additions and 4 deletions
|
|
@ -168,7 +168,7 @@ pub fn Objects(options: ObjectsOptions, comptime T: type) type {
|
||||||
|
|
||||||
// If we are tracking fields, we need to resize the bitset to hold another object's fields
|
// If we are tracking fields, we need to resize the bitset to hold another object's fields
|
||||||
if (objs.internal.updated) |*updated_fields| {
|
if (objs.internal.updated) |*updated_fields| {
|
||||||
try updated_fields.resize(allocator, data.capacity * @typeInfo(T).@"struct".fields.len, false);
|
try updated_fields.resize(allocator, data.capacity * @typeInfo(T).@"struct".fields.len, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
const index = data.len;
|
const index = data.len;
|
||||||
|
|
@ -324,15 +324,16 @@ pub fn Objects(options: ObjectsOptions, comptime T: type) type {
|
||||||
if (!options.track_fields) return false;
|
if (!options.track_fields) return false;
|
||||||
const unpacked = objs.validateAndUnpack(id, "updated");
|
const unpacked = objs.validateAndUnpack(id, "updated");
|
||||||
const updated_fields = &(objs.internal.updated orelse return false);
|
const updated_fields = &(objs.internal.updated orelse return false);
|
||||||
|
var any_updated = false;
|
||||||
inline for (0..@typeInfo(T).@"struct".fields.len) |field_index| {
|
inline for (0..@typeInfo(T).@"struct".fields.len) |field_index| {
|
||||||
const updated_index = unpacked.index * @typeInfo(T).@"struct".fields.len + field_index;
|
const updated_index = unpacked.index * @typeInfo(T).@"struct".fields.len + field_index;
|
||||||
const updated_value = updated_fields.isSet(updated_index);
|
const updated_value = updated_fields.isSet(updated_index);
|
||||||
|
updated_fields.unset(updated_index);
|
||||||
if (updated_value) {
|
if (updated_value) {
|
||||||
updated_fields.unset(updated_index);
|
any_updated = true;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return any_updated;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Tells if the given object is from this pool of objects. If it is, then it must also be
|
/// Tells if the given object is from this pool of objects. If it is, then it must also be
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue