[llvm] [dsymutil] Avoid repeated hash lookups (NFC) (#126190) (PR #126346)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 7 20:56:25 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-debuginfo
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/126346.diff
1 Files Affected:
- (modified) llvm/tools/dsymutil/BinaryHolder.cpp (+3-4)
``````````diff
diff --git a/llvm/tools/dsymutil/BinaryHolder.cpp b/llvm/tools/dsymutil/BinaryHolder.cpp
index 5daaa6755b2957f..7588a33eb46b22a 100644
--- a/llvm/tools/dsymutil/BinaryHolder.cpp
+++ b/llvm/tools/dsymutil/BinaryHolder.cpp
@@ -176,8 +176,8 @@ BinaryHolder::ArchiveEntry::getObjectEntry(StringRef Filename,
// Try the cache first.
std::lock_guard<std::mutex> Lock(MemberCacheMutex);
- if (MemberCache.count(Key))
- return *MemberCache[Key];
+ if (auto It = MemberCache.find(Key); It != MemberCache.end())
+ return *It->second;
// Create a new ObjectEntry, but don't add it to the cache yet. Loading of
// the archive members might fail and we don't want to lock the whole archive
@@ -228,8 +228,7 @@ BinaryHolder::ArchiveEntry::getObjectEntry(StringRef Filename,
if (OE->Objects.empty())
return errorCodeToError(errc::no_such_file_or_directory);
- MemberCache[Key] = std::move(OE);
- return *MemberCache[Key];
+ return *(MemberCache[Key] = std::move(OE));
}
Expected<const BinaryHolder::ObjectEntry &>
``````````
</details>
https://github.com/llvm/llvm-project/pull/126346
More information about the llvm-commits
mailing list