From c32fbee90530c3a261f57103e87691a34a2109fb Mon Sep 17 00:00:00 2001 From: reverse Date: Wed, 19 Aug 2026 01:29:48 +0000 Subject: [PATCH] chanlog: fan the mirrored notice via to_channel (Arc-shared line, per-recipient server-time) instead of collecting a members Vec and cloning the String per member --- src/modules/chanlog.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/modules/chanlog.rs b/src/modules/chanlog.rs index baa3f74..673d201 100644 --- a/src/modules/chanlog.rs +++ b/src/modules/chanlog.rs @@ -3,7 +3,6 @@ //! `chanlog = #channel` is configured. use crate::server::Server; -use crate::Uid; /// Tee `msg` to the configured chanlog channel (if set and it exists). Called at /// the tail of `Server::snotice`. Read-only over server state, so it can't loop. @@ -11,12 +10,12 @@ pub fn tee(s: &Server, msg: &str) { let Some(chan) = s.conf("chanlog") else { return; }; - let Some(ch) = s.channels.get(&chan.to_ascii_lowercase()) else { + let key = chan.to_ascii_lowercase(); + if !s.channels.contains_key(&key) { return; // channel not created yet — nothing to log into - }; - let line = format!(":{} NOTICE {chan} :{msg}", s.name); - let members: Vec = ch.members.keys().copied().collect(); - for u in members { - s.send(u, line.clone()); } + // to_channel builds the line once and shares it by Arc across members (and adds + // the server-time tag per recipient) instead of cloning a String per member. + let line = format!(":{} NOTICE {chan} :{msg}", s.name); + s.to_channel(&key, &line, None); }