mirror of
https://mzte.de/git/LordMZTE/dotfiles.git
synced 2024-06-02 03:19:54 +02:00
remove uneccessary alloc from playtwitch
This commit is contained in:
parent
82a39bf326
commit
7da71e6865
|
@ -23,7 +23,7 @@ chatty: bool,
|
|||
chatty_alive: bool,
|
||||
|
||||
/// an array of channels, composed of slices into `channels_file_data`
|
||||
channels: ?[]*ChannelEntry,
|
||||
channels: ?[]ChannelEntry,
|
||||
|
||||
/// the data of the channels configuration file
|
||||
channels_file_data: ?[]u8,
|
||||
|
@ -90,9 +90,6 @@ pub fn deinit(self: *Self) void {
|
|||
self.freeStreamlinkMemfd();
|
||||
|
||||
if (self.channels) |ch| {
|
||||
for (ch) |e| {
|
||||
std.heap.c_allocator.destroy(e);
|
||||
}
|
||||
std.heap.c_allocator.free(ch);
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ pub fn configLoaderThread(state: *State) !void {
|
|||
defer file.close();
|
||||
|
||||
const channels_data = try file.readToEndAlloc(std.heap.c_allocator, std.math.maxInt(usize));
|
||||
var channels = std.ArrayList(*State.ChannelEntry).init(std.heap.c_allocator);
|
||||
var channels = std.ArrayList(State.ChannelEntry).init(std.heap.c_allocator);
|
||||
|
||||
var channels_iter = std.mem.split(u8, channels_data, "\n");
|
||||
while (channels_iter.next()) |line| {
|
||||
|
@ -49,14 +49,10 @@ pub fn configLoaderThread(state: *State) !void {
|
|||
break :blk comment_trimmed;
|
||||
};
|
||||
|
||||
const entry = try std.heap.c_allocator.create(State.ChannelEntry);
|
||||
|
||||
entry.* = .{
|
||||
try channels.append(.{
|
||||
.name = channel_trimmed,
|
||||
.comment = comment_trimmed,
|
||||
};
|
||||
|
||||
try channels.append(entry);
|
||||
});
|
||||
}
|
||||
|
||||
const end_time = std.time.milliTimestamp();
|
||||
|
|
|
@ -8,7 +8,7 @@ pub fn reloadLiveThread(s: *State) !void {
|
|||
s.mutex.lock();
|
||||
defer s.mutex.unlock();
|
||||
|
||||
for (s.channels.?) |chan| {
|
||||
for (s.channels.?) |*chan| {
|
||||
chan.live = .loading;
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ pub fn fetchChannelsLive(s: *State) !void {
|
|||
// we shouldn't need to aquire the mutex here, this data isnt being read and we're
|
||||
// only doing atomic writes.
|
||||
var fmt_buf: [512]u8 = undefined;
|
||||
for (s.channels.?) |chan| {
|
||||
for (s.channels.?) |*chan| {
|
||||
page_buf.clearRetainingCapacity();
|
||||
|
||||
log.info("requesting live state for channel {s}", .{chan.name});
|
||||
|
|
Loading…
Reference in a new issue