https://github.com/kazutakahirata updated https://github.com/llvm/llvm-project/pull/112823
>From 621d5b5a767daa4046dffec522c39e4bc652ac1b Mon Sep 17 00:00:00 2001 From: Kazu Hirata <k...@google.com> Date: Thu, 17 Oct 2024 07:52:35 -0700 Subject: [PATCH 1/2] [lldb] Avoid repeated map lookups (NFC) --- lldb/source/Commands/CommandObjectMultiword.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) 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) >From 06d30396715b8cb5d2e4e67e904f62329e84f09f Mon Sep 17 00:00:00 2001 From: Kazu Hirata <k...@google.com> Date: Fri, 18 Oct 2024 08:51:41 -0700 Subject: [PATCH 2/2] Use pos at one more place. --- lldb/source/Commands/CommandObjectMultiword.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lldb/source/Commands/CommandObjectMultiword.cpp b/lldb/source/Commands/CommandObjectMultiword.cpp index 71339bd0f28b41..b4cdfea9b1a3ef 100644 --- a/lldb/source/Commands/CommandObjectMultiword.cpp +++ b/lldb/source/Commands/CommandObjectMultiword.cpp @@ -115,7 +115,7 @@ llvm::Error CommandObjectMultiword::LoadUserSubcommand( if (error_str) { return llvm::createStringError(llvm::inconvertibleErrorCode(), error_str); } - m_subcommand_dict[str_name] = cmd_obj_sp; + pos->second = cmd_obj_sp; return llvm::Error::success(); } _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits