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:
parent
508e084ddf
commit
75ccf913ac
1 changed files with 2 additions and 5 deletions
|
|
@ -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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue