[llvm] 19b25a4 - [dsymutil] Avoid repeated hash lookups (NFC) (#131268)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 14 07:22:47 PDT 2025
Author: Kazu Hirata
Date: 2025-03-14T07:22:44-07:00
New Revision: 19b25a45243948d0d55e0b42d82bb7705c775b77
URL: https://github.com/llvm/llvm-project/commit/19b25a45243948d0d55e0b42d82bb7705c775b77
DIFF: https://github.com/llvm/llvm-project/commit/19b25a45243948d0d55e0b42d82bb7705c775b77.diff
LOG: [dsymutil] Avoid repeated hash lookups (NFC) (#131268)
Added:
Modified:
llvm/tools/dsymutil/BinaryHolder.cpp
Removed:
################################################################################
diff --git a/llvm/tools/dsymutil/BinaryHolder.cpp b/llvm/tools/dsymutil/BinaryHolder.cpp
index 9429afeefa642..58751bddd3ba7 100644
--- a/llvm/tools/dsymutil/BinaryHolder.cpp
+++ b/llvm/tools/dsymutil/BinaryHolder.cpp
@@ -242,9 +242,9 @@ BinaryHolder::getObjectEntry(StringRef Filename, TimestampTy Timestamp) {
StringRef ArchiveFilename = getArchiveAndObjectName(Filename).first;
std::lock_guard<std::mutex> Lock(ArchiveCacheMutex);
ArchiveRefCounter[ArchiveFilename]++;
- if (ArchiveCache.count(ArchiveFilename)) {
- return ArchiveCache[ArchiveFilename]->getObjectEntry(Filename, Timestamp,
- Opts);
+ if (auto It = ArchiveCache.find(ArchiveFilename);
+ It != ArchiveCache.end()) {
+ return It->second->getObjectEntry(Filename, Timestamp, Opts);
} else {
auto AE = std::make_unique<ArchiveEntry>();
auto Err = AE->load(VFS, Filename, Timestamp, Opts);
@@ -252,9 +252,9 @@ BinaryHolder::getObjectEntry(StringRef Filename, TimestampTy Timestamp) {
// Don't return the error here: maybe the file wasn't an archive.
llvm::consumeError(std::move(Err));
} else {
- ArchiveCache[ArchiveFilename] = std::move(AE);
- return ArchiveCache[ArchiveFilename]->getObjectEntry(Filename,
- Timestamp, Opts);
+ auto &Cache = ArchiveCache[ArchiveFilename];
+ Cache = std::move(AE);
+ return Cache->getObjectEntry(Filename, Timestamp, Opts);
}
}
}
More information about the llvm-commits
mailing list