From 51a2948e7bcad30f1a13892009d587cd7cf3d17c Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Fri, 22 Jul 2022 16:18:45 +0100 Subject: Improve the performance of AddCommand slightly. --- src/command_parse.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'src/command_parse.cpp') diff --git a/src/command_parse.cpp b/src/command_parse.cpp index 2288097d0..c74556ad3 100644 --- a/src/command_parse.cpp +++ b/src/command_parse.cpp @@ -359,15 +359,9 @@ void CommandParser::ProcessBuffer(LocalUser* user, const std::string& buffer) ProcessCommand(user, command, parameters); } -bool CommandParser::AddCommand(Command *f) +bool CommandParser::AddCommand(Command* cmd) { - /* create the command and push it onto the table */ - if (cmdlist.find(f->name) == cmdlist.end()) - { - cmdlist[f->name] = f; - return true; - } - return false; + return cmdlist.emplace(cmd->name, cmd).second; } std::string CommandParser::TranslateUIDs(const std::vector& to, const CommandBase::Params& source, bool prefix_final, CommandBase* custom_translator) -- cgit v1.3.1-10-gc9f91