aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Commands/CommandObjectMultiword.cpp
diff options
context:
space:
mode:
authorKazu Hirata <kazu@google.com>2024-10-18 10:40:13 -0700
committerGitHub <noreply@github.com>2024-10-18 10:40:13 -0700
commita01d7df09048e0b0b002c3f8420bcc8c7eab3ea0 (patch)
treec4fc6405ae125276618994ba27de16491232591f /lldb/source/Commands/CommandObjectMultiword.cpp
parent9120adea504981dfd55ace25825f84018543d6f2 (diff)
downloadllvm-a01d7df09048e0b0b002c3f8420bcc8c7eab3ea0.zip
llvm-a01d7df09048e0b0b002c3f8420bcc8c7eab3ea0.tar.gz
llvm-a01d7df09048e0b0b002c3f8420bcc8c7eab3ea0.tar.bz2
[lldb] Avoid repeated map lookups (NFC) (#112823)
Diffstat (limited to 'lldb/source/Commands/CommandObjectMultiword.cpp')
-rw-r--r--lldb/source/Commands/CommandObjectMultiword.cpp8
1 files changed, 3 insertions, 5 deletions
diff --git a/lldb/source/Commands/CommandObjectMultiword.cpp b/lldb/source/Commands/CommandObjectMultiword.cpp
index 484d902..b4cdfea 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)
@@ -117,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();
}