-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[lldb-dap] Use heterogenous lookups with std::map (NFC) #115590
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
kazutakahirata
merged 1 commit into
llvm:main
from
kazutakahirata:cleanup_001_heterogenous_lldb_dap
Nov 9, 2024
Merged
[lldb-dap] Use heterogenous lookups with std::map (NFC) #115590
kazutakahirata
merged 1 commit into
llvm:main
from
kazutakahirata:cleanup_001_heterogenous_lldb_dap
Nov 9, 2024
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Heterogenous lookups allow us to call find with StringRef, avoiding a temporary heap allocation of std::string.
@llvm/pr-subscribers-lldb Author: Kazu Hirata (kazutakahirata) ChangesHeterogenous lookups allow us to call find with StringRef, avoiding a Full diff: https://github.com/llvm/llvm-project/pull/115590.diff 2 Files Affected:
diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index 647e28080b6339..e45f9bf359e5bf 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -692,7 +692,7 @@ bool DAP::HandleObject(const llvm::json::Object &object) {
const auto packet_type = GetString(object, "type");
if (packet_type == "request") {
const auto command = GetString(object, "command");
- auto handler_pos = request_handlers.find(std::string(command));
+ auto handler_pos = request_handlers.find(command);
if (handler_pos != request_handlers.end()) {
handler_pos->second(object);
return true; // Success
diff --git a/lldb/tools/lldb-dap/DAP.h b/lldb/tools/lldb-dap/DAP.h
index dab4ce44ab202c..1641a58c7dbd06 100644
--- a/lldb/tools/lldb-dap/DAP.h
+++ b/lldb/tools/lldb-dap/DAP.h
@@ -171,7 +171,7 @@ struct DAP {
// the old process here so we can detect this case and keep running.
lldb::pid_t restarting_process_id;
bool configuration_done_sent;
- std::map<std::string, RequestCallback> request_handlers;
+ std::map<std::string, RequestCallback, std::less<>> request_handlers;
bool waiting_for_run_in_terminal;
ProgressEventReporter progress_event_reporter;
// Keep track of the last stop thread index IDs as threads won't go away
|
nikic
approved these changes
Nov 9, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
kazutakahirata
added a commit
to kazutakahirata/llvm-project
that referenced
this pull request
Nov 10, 2024
Heterogenous lookups allow us to call find with StringRef, avoiding a temporary heap allocation of std::string.
kazutakahirata
added a commit
that referenced
this pull request
Nov 10, 2024
Groverkss
pushed a commit
to iree-org/llvm-project
that referenced
this pull request
Nov 15, 2024
Heterogenous lookups allow us to call find with StringRef, avoiding a temporary heap allocation of std::string.
Groverkss
pushed a commit
to iree-org/llvm-project
that referenced
this pull request
Nov 15, 2024
…vm#115634) Heterogenous lookups allow us to call find with StringRef, avoiding a temporary heap allocation of std::string.
JDevlieghere
pushed a commit
to swiftlang/llvm-project
that referenced
this pull request
Feb 25, 2025
Heterogenous lookups allow us to call find with StringRef, avoiding a temporary heap allocation of std::string. (cherry picked from commit c3c424d)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Heterogenous lookups allow us to call find with StringRef, avoiding a
temporary heap allocation of std::string.