[Lldb-commits] [lldb] [lldb] Avoid repeated map lookups (NFC) (PR #112315)
via lldb-commits
lldb-commits at lists.llvm.org
Mon Oct 14 23:23:36 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-lldb
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/112315.diff
1 Files Affected:
- (modified) lldb/source/Commands/CommandObjectMultiword.cpp (+1-10)
``````````diff
diff --git a/lldb/source/Commands/CommandObjectMultiword.cpp b/lldb/source/Commands/CommandObjectMultiword.cpp
index 4efa5652a71703..8e9f91c64140ea 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 different 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(
``````````
</details>
https://github.com/llvm/llvm-project/pull/112315
More information about the lldb-commits
mailing list