[Lldb-commits] [lldb] [lldb] Avoid repeated map lookups (NFC) (PR #112823)
via lldb-commits
lldb-commits at lists.llvm.org
Thu Oct 17 20:27:14 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/112823.diff
1 Files Affected:
- (modified) lldb/source/Commands/CommandObjectMultiword.cpp (+2-4)
``````````diff
diff --git a/lldb/source/Commands/CommandObjectMultiword.cpp b/lldb/source/Commands/CommandObjectMultiword.cpp
index 484d9022027ec6..71339bd0f28b41 100644
--- a/lldb/source/Commands/CommandObjectMultiword.cpp
+++ b/lldb/source/Commands/CommandObjectMultiword.cpp
@@ -102,11 +102,9 @@ llvm::Error CommandObjectMultiword::LoadUserSubcommand(
std::string str_name(name);
- auto pos = m_subcommand_dict.find(str_name);
- if (pos == m_subcommand_dict.end()) {
- m_subcommand_dict[str_name] = cmd_obj_sp;
+ auto [pos, inserted] = m_subcommand_dict.try_emplace(str_name, cmd_obj_sp);
+ if (inserted)
return llvm::Error::success();
- }
const char *error_str = nullptr;
if (!can_replace)
``````````
</details>
https://github.com/llvm/llvm-project/pull/112823
More information about the lldb-commits
mailing list