Skip to content
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

[lld] Avoid repeated hash lookups (NFC) #112119

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

kazutakahirata
Copy link
Contributor

No description provided.

@llvmbot
Copy link
Collaborator

llvmbot commented Oct 13, 2024

@llvm/pr-subscribers-lld

Author: Kazu Hirata (kazutakahirata)

Changes

Full diff: https:/llvm/llvm-project/pull/112119.diff

1 Files Affected:

  • (modified) lld/ELF/Arch/ARM.cpp (+3-2)
diff --git a/lld/ELF/Arch/ARM.cpp b/lld/ELF/Arch/ARM.cpp
index 7a7348c04a88c0..2219d2d6ce0c41 100644
--- a/lld/ELF/Arch/ARM.cpp
+++ b/lld/ELF/Arch/ARM.cpp
@@ -1103,10 +1103,11 @@ static void toLittleEndianInstructions(uint8_t *buf, uint64_t start,
 // [$t, non $t) and convert these to little endian a word or half word at a
 // time respectively.
 void elf::convertArmInstructionstoBE8(InputSection *sec, uint8_t *buf) {
-  if (!sectionMap.contains(sec))
+  auto it = sectionMap.find(sec);
+  if (it == sectionMap.end())
     return;
 
-  SmallVector<const Defined *, 0> &mapSyms = sectionMap[sec];
+  SmallVector<const Defined *, 0> &mapSyms = it->second;
 
   if (mapSyms.empty())
     return;

@llvmbot
Copy link
Collaborator

llvmbot commented Oct 13, 2024

@llvm/pr-subscribers-lld-elf

Author: Kazu Hirata (kazutakahirata)

Changes

Full diff: https:/llvm/llvm-project/pull/112119.diff

1 Files Affected:

  • (modified) lld/ELF/Arch/ARM.cpp (+3-2)
diff --git a/lld/ELF/Arch/ARM.cpp b/lld/ELF/Arch/ARM.cpp
index 7a7348c04a88c0..2219d2d6ce0c41 100644
--- a/lld/ELF/Arch/ARM.cpp
+++ b/lld/ELF/Arch/ARM.cpp
@@ -1103,10 +1103,11 @@ static void toLittleEndianInstructions(uint8_t *buf, uint64_t start,
 // [$t, non $t) and convert these to little endian a word or half word at a
 // time respectively.
 void elf::convertArmInstructionstoBE8(InputSection *sec, uint8_t *buf) {
-  if (!sectionMap.contains(sec))
+  auto it = sectionMap.find(sec);
+  if (it == sectionMap.end())
     return;
 
-  SmallVector<const Defined *, 0> &mapSyms = sectionMap[sec];
+  SmallVector<const Defined *, 0> &mapSyms = it->second;
 
   if (mapSyms.empty())
     return;

Copy link
Contributor

@nikic nikic left a comment

Choose a reason for hiding this comment

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

LGTM

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

Successfully merging this pull request may close these issues.

3 participants