From 08b3841a8cf362d97fcea64c178dc12eeeb19a54 Mon Sep 17 00:00:00 2001 From: "Craig Edwards (Brain)" Date: Wed, 9 Oct 2024 00:02:56 +0100 Subject: [PATCH] Update cluster.h --- include/dpp/cluster.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/include/dpp/cluster.h b/include/dpp/cluster.h index 4e8734b125..787b95d854 100644 --- a/include/dpp/cluster.h +++ b/include/dpp/cluster.h @@ -493,11 +493,8 @@ class DPP_EXPORT cluster { std::enable_if_t, dpp::task>, bool> register_command(const std::string& name, F&& handler){ std::unique_lock lk(named_commands_mutex); - if (named_commands.count(name) != 0) { - return false; - } - named_commands.emplace(name, handler); - return true; + auto [_, inserted] = named_commands.try_emplace(name, handler); + return inserted; }; #endif