From 9efee4531261898c5c1666d010a22eab4f3ea457 Mon Sep 17 00:00:00 2001 From: rebecca Date: Fri, 25 Sep 2026 16:33:35 +0100 Subject: deduplicate add_channel loops --- main.lua | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'main.lua') diff --git a/main.lua b/main.lua index d5469d0..bf9a0b6 100644 --- a/main.lua +++ b/main.lua @@ -46,13 +46,19 @@ function Wilson.make(cls, conf) return self end --- find bus containing given channel +function Wilson.add_channels_for(self, pylon) + if not pylon.add_channel then return end + for busname, bus in pairs(self.busses) do + for _, channel in ipairs(bus) do + if channel.pylon == pylon then + pylon:add_channel(channel) +end end end end + function Wilson._find_bus(self, channel) for name, bus in pairs(self.busses) do for _, q in ipairs(bus) do if q == channel then return bus end end end - self.log:warn("unfound bus for",channel) -end + self.log:warn("unfound bus for",channel) end function Wilson.deliver(self, message) local bus = self:_find_bus(assert(message.channel)) if bus then @@ -61,10 +67,7 @@ function Wilson.deliver(self, message) if message.channel ~= dest_channel then self.log:debug(message.channel, "-->", dest_channel, message) dest_channel.pylon:post(dest_channel, message) - end - end - end -end +end end end end function Wilson.run(self) for pylonname, pylon in pairs(self.pylons) do self.cq:wrap(pylon.run, pylon) -- cgit v1.2.3