From 80a381c76a91d89caed6eca5c6f152ed7ae87dfd Mon Sep 17 00:00:00 2001 From: Bram Matthys Date: Mon, 29 Sep 2025 17:17:20 +0200 Subject: [PATCH] Optimization: history: use HasCapabilityFast() instead of HasCapability() This makes it so the capability bit lookup is done only once on module load and not on each client JOIN. --- src/modules/chanmodes/history.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/modules/chanmodes/history.c b/src/modules/chanmodes/history.c index 4883cdcc9..29db69db0 100644 --- a/src/modules/chanmodes/history.c +++ b/src/modules/chanmodes/history.c @@ -37,6 +37,9 @@ Cmode_t EXTMODE_HISTORY = 0L; static cfgstruct cfg; static cfgstruct test; +/* Externally looked up */ +long CAP_CHATHISTORY_DRAFT = 0; + #define HistoryEnabled(channel) (channel->mode.mode & EXTMODE_HISTORY) /* Forward declarations */ @@ -99,6 +102,7 @@ MOD_INIT() MOD_LOAD() { + long CAP_CHATHISTORY_DRAFT = ClientCapabilityBit("draft/chathistory"); CommandOverrideAdd(modinfo->handle, "MODE", 0, override_mode); CommandOverrideAdd(modinfo->handle, "SVSMODE", 0, override_mode); CommandOverrideAdd(modinfo->handle, "SVS2MODE", 0, override_mode); @@ -688,7 +692,7 @@ int history_join(Client *client, Channel *channel, MessageTag *mtags) /* No history-on-join for clients that implement CHATHISTORY, * they will pull history themselves if they need it. */ - if (HasCapability(client, "draft/chathistory") /*|| HasCapability(client, "chathistory")*/) + if (HasCapabilityFast(client, CAP_CHATHISTORY_DRAFT) /*|| HasCapabilityFast(client, CAP_CHATHISTORY)*/) return 0; if (MyUser(client) && can_receive_history(client))