Skip to content

[lldb] Avoid repeated map lookups (NFC) #112655

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

Conversation

kazutakahirata
Copy link
Contributor

No description provided.

@llvmbot
Copy link
Member

llvmbot commented Oct 17, 2024

@llvm/pr-subscribers-lldb

Author: Kazu Hirata (kazutakahirata)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/112655.diff

1 Files Affected:

  • (modified) lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (+1-1)
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index 3e09c316d74f44..70cbd1c57b895a 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -5324,7 +5324,7 @@ std::string ProcessGDBRemote::HarmonizeThreadIdsForProfileData(
         std::map<uint64_t, uint32_t>::iterator iterator =
             m_thread_id_to_used_usec_map.find(thread_id);
         if (iterator != m_thread_id_to_used_usec_map.end()) {
-          prev_used_usec = m_thread_id_to_used_usec_map[thread_id];
+          prev_used_usec = iterator->second;
         }
 
         uint32_t real_used_usec = curr_used_usec - prev_used_usec;

Copy link
Member

@JDevlieghere JDevlieghere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@felipepiovezan
Copy link
Contributor

Thanks for finding those, there are many places in LLDB doing repeated work like this!

@kazutakahirata kazutakahirata merged commit 9173fd7 into llvm:main Oct 17, 2024
7 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_001_repeated_hash_lldb branch October 17, 2024 14:45
@jimingham
Copy link
Collaborator

jimingham commented Oct 17, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants