Skip to content

Commit a7b7af7

Browse files
[lldb] Avoid repeated map lookups (NFC) (llvm#112315)
1 parent b43cfa7 commit a7b7af7

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

lldb/source/Commands/CommandObjectMultiword.cpp

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,16 +84,7 @@ bool CommandObjectMultiword::LoadSubCommand(llvm::StringRef name,
8484
lldbassert((&GetCommandInterpreter() == &cmd_obj_sp->GetCommandInterpreter()) &&
8585
"tried to add a CommandObject from a different interpreter");
8686

87-
CommandMap::iterator pos;
88-
bool success = true;
89-
90-
pos = m_subcommand_dict.find(std::string(name));
91-
if (pos == m_subcommand_dict.end()) {
92-
m_subcommand_dict[std::string(name)] = cmd_obj_sp;
93-
} else
94-
success = false;
95-
96-
return success;
87+
return m_subcommand_dict.try_emplace(std::string(name), cmd_obj_sp).second;
9788
}
9889

9990
llvm::Error CommandObjectMultiword::LoadUserSubcommand(

0 commit comments

Comments
 (0)