diff options
Diffstat (limited to 'src/storage/image-manager/root.zig')
| -rw-r--r-- | src/storage/image-manager/root.zig | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/src/storage/image-manager/root.zig b/src/storage/image-manager/root.zig index 7fa1607..4188b88 100644 --- a/src/storage/image-manager/root.zig +++ b/src/storage/image-manager/root.zig @@ -60,24 +60,22 @@ pub fn add(self: *Self, allocator: std.mem.Allocator, image: Image) !void { var current = self.timestamp_order.first; - if (current == null) { - const timestamp = try allocator.create(Timestamp); - timestamp.index = self.items.items.len - 1; - self.timestamp_order.append(×tamp.node); - return; - } - while (current) |c| { const index = @as(*Timestamp, @fieldParentPtr("node", c)).index; if (image.timestamp orelse 0 > self.items.items[index].timestamp orelse 0) { const timestamp = try allocator.create(Timestamp); timestamp.index = self.items.items.len - 1; self.timestamp_order.insertBefore(c, ×tamp.node); - break; + return; } current = c.next; } + + const timestamp = try allocator.create(Timestamp); + timestamp.index = self.items.items.len - 1; + self.timestamp_order.append(×tamp.node); + return; } pub fn save( |