From 17950178cdf55c59cf7c44dd9f583bc1d76c60ef Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Sun, 18 Sep 2022 22:56:39 +0100 Subject: Avoid creating duplicate account API instances in ircv3_accounttag. --- src/modules/m_ircv3_accounttag.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src/modules') diff --git a/src/modules/m_ircv3_accounttag.cpp b/src/modules/m_ircv3_accounttag.cpp index b4087fd8c..eb3cf8b72 100644 --- a/src/modules/m_ircv3_accounttag.cpp +++ b/src/modules/m_ircv3_accounttag.cpp @@ -27,7 +27,7 @@ class AccountTag final : public IRCv3::CapTag { private: - Account::API accountapi; + Account::API& accountapi; public: const std::string* GetValue(const ClientProtocol::Message& msg) const @@ -39,9 +39,9 @@ public: return accountapi->GetAccountName(user); } - AccountTag(Module* mod) + AccountTag(Module* mod, Account::API& api) : IRCv3::CapTag(mod, "account-tag", "account") - , accountapi(mod) + , accountapi(api) { } }; @@ -50,14 +50,14 @@ class AccountIdTag final : public ClientProtocol::MessageTagProvider { private: - Account::API accountapi; + Account::API& accountapi; AccountTag& acctag; CTCTags::CapReference ctctagcap; public: - AccountIdTag(Module* mod, AccountTag& tag) + AccountIdTag(Module* mod, AccountTag& tag, Account::API& api) : ClientProtocol::MessageTagProvider(mod) - , accountapi(mod) + , accountapi(api) , acctag(tag) , ctctagcap(mod) { @@ -84,14 +84,16 @@ class ModuleIRCv3AccountTag final : public Module { private: + Account::API accountapi; AccountTag tag; AccountIdTag idtag; public: ModuleIRCv3AccountTag() : Module(VF_VENDOR, "Provides the IRCv3 account-tag client capability.") - , tag(this) - , idtag(this, tag) + , accountapi(this) + , tag(this, accountapi) + , idtag(this, tag, accountapi) { } }; -- cgit v1.3.1-10-gc9f91