Skip to content

Commit a01d7df

Browse files
[lldb] Avoid repeated map lookups (NFC) (#112823)
1 parent 9120ade commit a01d7df

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

lldb/source/Commands/CommandObjectMultiword.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,9 @@ llvm::Error CommandObjectMultiword::LoadUserSubcommand(
102102

103103
std::string str_name(name);
104104

105-
auto pos = m_subcommand_dict.find(str_name);
106-
if (pos == m_subcommand_dict.end()) {
107-
m_subcommand_dict[str_name] = cmd_obj_sp;
105+
auto [pos, inserted] = m_subcommand_dict.try_emplace(str_name, cmd_obj_sp);
106+
if (inserted)
108107
return llvm::Error::success();
109-
}
110108

111109
const char *error_str = nullptr;
112110
if (!can_replace)
@@ -117,7 +115,7 @@ llvm::Error CommandObjectMultiword::LoadUserSubcommand(
117115
if (error_str) {
118116
return llvm::createStringError(llvm::inconvertibleErrorCode(), error_str);
119117
}
120-
m_subcommand_dict[str_name] = cmd_obj_sp;
118+
pos->second = cmd_obj_sp;
121119
return llvm::Error::success();
122120
}
123121

0 commit comments

Comments
 (0)