╭──────────╮ │← previous│ ╰──────────╯ ╭ changed ────╮ │src/event.zig│ ╰─────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────╮ │1353 // created only once a field actually changes │ │1354 var field_oids: ?DB.SortedMap(.read_write) = null; │ │1355 │ │1356 - inline for (std.meta.fields(T)) |field| { │ │1356 + const info = @typeInfo(T).@"struct"; │ │1357 + inline for (info.field_names, info.field_types) |field_name, field_type| { │ │1358 const changed = if (existing_maybe) |existing| │ │1358 - !fieldEqual(field.type, @field(existing, field.name), @field(event, field.name))│ │1359 + !fieldEqual(field_type, @field(existing, field_name), @field(event, field_name))│ │1360 else │ │1361 true; │ │1362 if (changed) { │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │1363 if (field_oids == null) { │ │1364 field_oids = try DB.SortedMap(.read_write).init(try id_to_field_to_oid.putCursor(record_key));│ │1365 } │ │1365 - if (field_oids) |map| try map.put(field.name, .{ .bytes = oid }); │ │1366 + if (field_oids) |map| try map.put(field_name, .{ .bytes = oid }); │ │1367 } │ │1368 } │ │1369 } │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────╮ │1371 // the whole field list, space separated, is the longest it can get │ │1372 fn conflictedFieldsMaxLen(comptime T: type) usize { │ │1373 var len: usize = 0; │ │1373 - for (std.meta.fields(T)) |field| len += field.name.len + 1; │ │1374 + for (@typeInfo(T).@"struct".field_names) |name| len += name.len + 1;│ │1375 return len; │ │1376 } │ │1377 │ ╰──────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────╮ │1397 baseline_maybe: ?T, │ │1398 target: T, │ │1399 parent: T, │ │1399 - outcome: *[std.meta.fields(T).len]FieldMerge, │ │1400 + outcome: *[@typeInfo(T).@"struct".field_names.len]FieldMerge,│ │1401 ) T { │ │1402 var merged = target; │ │1403 │ ╰───────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────╮ │1403 - inline for (std.meta.fields(T), 0..) |field, i| { │ │1404 - const target_value = @field(target, field.name); │ │1405 - const parent_value = @field(parent, field.name); │ │1404 + const info = @typeInfo(T).@"struct"; │ │1405 + inline for (info.field_names, info.field_types, 0..) |field_name, field_type, i| {│ │1406 + const target_value = @field(target, field_name); │ │1407 + const parent_value = @field(parent, field_name); │ │1408 │ │1407 - if (!fieldEqual(field.type, target_value, parent_value)) { │ │1409 + if (!fieldEqual(field_type, target_value, parent_value)) { │ │1410 outcome[i] = if (baseline_maybe) |baseline| blk: { │ │1409 - const baseline_value = @field(baseline, field.name); │ │1410 - if (fieldEqual(field.type, target_value, baseline_value)) { │ │1411 - @field(merged, field.name) = parent_value; │ │1411 + const baseline_value = @field(baseline, field_name); │ │1412 + if (fieldEqual(field_type, target_value, baseline_value)) { │ │1413 + @field(merged, field_name) = parent_value; │ │1414 break :blk .parent; │ │1415 } │ │1416 // only the target changed it │ ╰────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────╮ │1415 - if (fieldEqual(field.type, parent_value, baseline_value)) break :blk .kept;│ │1417 + if (fieldEqual(field_type, parent_value, baseline_value)) break :blk .kept;│ │1418 break :blk .conflicted; │ │1419 } else .conflicted; │ │1420 } │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────╮ │1493 const target_records = try DB.HashMap(.read_write).init(target_records_cursor); │ │1494 │ │1495 // a record the target doesn't have arrives wholesale from the parent │ │1494 - var outcome: [std.meta.fields(T).len]FieldMerge = @splat(.parent); │ │1496 + var outcome: [@typeInfo(T).@"struct".field_names.len]FieldMerge = @splat(.parent);│ │1497 var merged = parent_record; │ │1498 │ │1499 if (try target_records.getCursor(record_key)) |target_record_cursor| { │ ╰────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────╮ │1593 var conflicted_fields: [conflictedFieldsMaxLen(T)]u8 = undefined; │ │1594 var conflicted_len: usize = 0; │ │1595 │ │1594 - inline for (std.meta.fields(T), 0..) |field, i| { │ │1596 + inline for (@typeInfo(T).@"struct".field_names, 0..) |field_name, i| {│ │1597 switch (outcome[i]) { │ │1598 // the target's value stands, so its oid does too │ │1599 .kept => {}, │ ╰────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │1606 field_oids = try DB.SortedMap(.read_write).init(try id_to_field_to_oid.putCursor(record_key)); │ │1607 } │ │1608 const map = field_oids orelse unreachable; │ │1607 - const parent_oid = if (parent_field_oids) |parent_map| try parent_map.getCursor(field.name) else null;│ │1609 + const parent_oid = if (parent_field_oids) |parent_map| try parent_map.getCursor(field_name) else null;│ │1610 if (parent_oid) |oid_cursor| { │ │1609 - try map.put(field.name, .{ .slot = oid_cursor.slot() }); │ │1611 + try map.put(field_name, .{ .slot = oid_cursor.slot() }); │ │1612 } else { │ │1611 - _ = try map.remove(field.name); │ │1613 + _ = try map.remove(field_name); │ │1614 } │ │1615 }, │ │1616 .conflicted => { │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────╮ │1618 conflicted_fields[conflicted_len] = ' '; │ │1619 conflicted_len += 1; │ │1620 } │ │1619 - @memcpy(conflicted_fields[conflicted_len..][0..field.name.len], field.name);│ │1620 - conflicted_len += field.name.len; │ │1621 + @memcpy(conflicted_fields[conflicted_len..][0..field_name.len], field_name);│ │1622 + conflicted_len += field_name.len; │ │1623 }, │ │1624 } │ │1625 } │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────╮ │next →│ ╰──────╯