Skip to content

Commit c3c424d

Browse files
[lldb-dap] Use heterogenous lookups with std::map (NFC) (#115590)
Heterogenous lookups allow us to call find with StringRef, avoiding a temporary heap allocation of std::string.
1 parent ccaded2 commit c3c424d

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

lldb/tools/lldb-dap/DAP.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,7 @@ bool DAP::HandleObject(const llvm::json::Object &object) {
692692
const auto packet_type = GetString(object, "type");
693693
if (packet_type == "request") {
694694
const auto command = GetString(object, "command");
695-
auto handler_pos = request_handlers.find(std::string(command));
695+
auto handler_pos = request_handlers.find(command);
696696
if (handler_pos != request_handlers.end()) {
697697
handler_pos->second(object);
698698
return true; // Success

lldb/tools/lldb-dap/DAP.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ struct DAP {
171171
// the old process here so we can detect this case and keep running.
172172
lldb::pid_t restarting_process_id;
173173
bool configuration_done_sent;
174-
std::map<std::string, RequestCallback> request_handlers;
174+
std::map<std::string, RequestCallback, std::less<>> request_handlers;
175175
bool waiting_for_run_in_terminal;
176176
ProgressEventReporter progress_event_reporter;
177177
// Keep track of the last stop thread index IDs as threads won't go away

0 commit comments

Comments
 (0)