[Lldb-commits] [lldb] a7b7af7 - [lldb] Avoid repeated map lookups (NFC) (#112315)
via lldb-commits
lldb-commits at lists.llvm.org
Tue Oct 15 07:37:08 PDT 2024
Author: Kazu Hirata
Date: 2024-10-15T07:37:00-07:00
New Revision: a7b7af7ad5c45fba87d9b423752601865cdfbee2
URL: https://github.com/llvm/llvm-project/commit/a7b7af7ad5c45fba87d9b423752601865cdfbee2
DIFF: https://github.com/llvm/llvm-project/commit/a7b7af7ad5c45fba87d9b423752601865cdfbee2.diff
LOG: [lldb] Avoid repeated map lookups (NFC) (#112315)
Added:
Modified:
lldb/source/Commands/CommandObjectMultiword.cpp
Removed:
################################################################################
diff --git a/lldb/source/Commands/CommandObjectMultiword.cpp b/lldb/source/Commands/CommandObjectMultiword.cpp
index ab3369c6f9c20a..484d9022027ec6 100644
--- a/lldb/source/Commands/CommandObjectMultiword.cpp
+++ b/lldb/source/Commands/CommandObjectMultiword.cpp
@@ -84,16 +84,7 @@ bool CommandObjectMultiword::LoadSubCommand(llvm::StringRef name,
lldbassert((&GetCommandInterpreter() == &cmd_obj_sp->GetCommandInterpreter()) &&
"tried to add a CommandObject from a
diff erent interpreter");
- CommandMap::iterator pos;
- bool success = true;
-
- pos = m_subcommand_dict.find(std::string(name));
- if (pos == m_subcommand_dict.end()) {
- m_subcommand_dict[std::string(name)] = cmd_obj_sp;
- } else
- success = false;
-
- return success;
+ return m_subcommand_dict.try_emplace(std::string(name), cmd_obj_sp).second;
}
llvm::Error CommandObjectMultiword::LoadUserSubcommand(
More information about the lldb-commits
mailing list