| ... | ... | @@ -285,13 +285,11 @@ pub const Node = struct { |
| 285 | 285 | assert(parent == .none or @intFromEnum(parent) < node_storage_buffer_len); |
| 286 | 286 | |
| 287 | 287 | const storage = storageByIndex(free_index); |
| 288 | | storage.* = .{ |
| 289 | | .completed_count = 0, |
| 290 | | .estimated_total_count = std.math.lossyCast(u32, estimated_total_items), |
| 291 | | .name = [1]u8{0} ** max_name_len, |
| 292 | | }; |
| 288 | @atomicStore(u32, &storage.completed_count, 0, .monotonic); |
| 289 | @atomicStore(u32, &storage.estimated_total_count, std.math.lossyCast(u32, estimated_total_items), .monotonic); |
| 293 | 290 | const name_len = @min(max_name_len, name.len); |
| 294 | | @memcpy(storage.name[0..name_len], name[0..name_len]); |
| 291 | for (storage.name[0..name_len], name[0..name_len]) |*dest, src| @atomicStore(u8, dest, src, .monotonic); |
| 292 | for (storage.name[name_len..]) |*dest| @atomicStore(u8, dest, 0, .monotonic); |
| 295 | 293 | |
| 296 | 294 | const parent_ptr = parentByIndex(free_index); |
| 297 | 295 | assert(parent_ptr.* == .unused); |
| ... | ... | @@ -765,7 +763,7 @@ fn serialize(serialized_buffer: *Serialized.Buffer) Serialized { |
| 765 | 763 | var begin_parent = @atomicLoad(Node.Parent, parent_ptr, .acquire); |
| 766 | 764 | while (begin_parent != .unused) { |
| 767 | 765 | const dest_storage = &serialized_buffer.storage[serialized_len]; |
| 768 | | @memcpy(&dest_storage.name, &storage_ptr.name); |
| 766 | for (&dest_storage.name, &storage_ptr.name) |*dest, *src| dest.* = @atomicLoad(u8, src, .monotonic); |
| 769 | 767 | dest_storage.estimated_total_count = @atomicLoad(u32, &storage_ptr.estimated_total_count, .acquire); |
| 770 | 768 | dest_storage.completed_count = @atomicLoad(u32, &storage_ptr.completed_count, .monotonic); |
| 771 | 769 | const end_parent = @atomicLoad(Node.Parent, parent_ptr, .acquire); |