refactor(bot.zig): deinit all backlog slots

Previously we deinited backwards from the most recently heard message
until we reach a null-slot.

Now this code has been simplified to walk the backlog and deinit any
found messages.
This commit is contained in:
Jacob Jonsson 2026-01-04 23:54:26 +01:00
parent 508e084ddf
commit 75ccf913ac
Signed by: Jassob
GPG key ID: 7E30B9B047F7202E

View file

@ -171,12 +171,9 @@ pub const Bot = struct {
} }
self.sent_messages.deinit(self.allocator); self.sent_messages.deinit(self.allocator);
var idx = self.previous_idx(self.top); for (self.backlog) |slot| {
while (idx != self.bottom) : (idx = self.previous_idx(idx)) { if (slot) |message| {
if (self.backlog[idx]) |message| {
message.deinit(self.allocator); message.deinit(self.allocator);
} else {
break;
} }
} }
} }