Skip to content

[lldb] Use heterogenous lookups with std::map (NFC) (#115590) #115634

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions lldb/include/lldb/Interpreter/CommandObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ namespace lldb_private {

template <typename ValueType>
int AddNamesMatchingPartialString(
const std::map<std::string, ValueType> &in_map, llvm::StringRef cmd_str,
StringList &matches, StringList *descriptions = nullptr) {
const std::map<std::string, ValueType, std::less<>> &in_map,
llvm::StringRef cmd_str, StringList &matches,
StringList *descriptions = nullptr) {
int number_added = 0;

const bool add_all = cmd_str.empty();
Expand All @@ -54,7 +55,8 @@ int AddNamesMatchingPartialString(
}

template <typename ValueType>
size_t FindLongestCommandWord(std::map<std::string, ValueType> &dict) {
size_t
FindLongestCommandWord(std::map<std::string, ValueType, std::less<>> &dict) {
auto end = dict.end();
size_t max_len = 0;

Expand Down Expand Up @@ -107,7 +109,7 @@ class CommandObject : public std::enable_shared_from_this<CommandObject> {
typedef std::vector<CommandArgumentData>
CommandArgumentEntry; // Used to build individual command argument lists

typedef std::map<std::string, lldb::CommandObjectSP> CommandMap;
typedef std::map<std::string, lldb::CommandObjectSP, std::less<>> CommandMap;

CommandObject(CommandInterpreter &interpreter, llvm::StringRef name,
llvm::StringRef help = "", llvm::StringRef syntax = "",
Expand Down
4 changes: 2 additions & 2 deletions lldb/source/Commands/CommandObjectMultiword.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ CommandObjectMultiword::GetSubcommandSPExact(llvm::StringRef sub_cmd) {
if (m_subcommand_dict.empty())
return {};

auto pos = m_subcommand_dict.find(std::string(sub_cmd));
auto pos = m_subcommand_dict.find(sub_cmd);
if (pos == m_subcommand_dict.end())
return {};

Expand Down Expand Up @@ -64,7 +64,7 @@ CommandObjectSP CommandObjectMultiword::GetSubcommandSP(llvm::StringRef sub_cmd,
// function, since I now know I have an exact match...

sub_cmd = matches->GetStringAtIndex(0);
pos = m_subcommand_dict.find(std::string(sub_cmd));
pos = m_subcommand_dict.find(sub_cmd);
if (pos != m_subcommand_dict.end())
return_cmd_sp = pos->second;
}
Expand Down
Loading