[llvm] 573df34 - [llvm-jitlink] Avoid repeated hash lookups (NFC) (#130465)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Mar 9 00:49:16 PST 2025
Author: Kazu Hirata
Date: 2025-03-09T00:49:13-08:00
New Revision: 573df34ea053a82de2d8fb28dd430bca94ddcaaa
URL: https://github.com/llvm/llvm-project/commit/573df34ea053a82de2d8fb28dd430bca94ddcaaa
DIFF: https://github.com/llvm/llvm-project/commit/573df34ea053a82de2d8fb28dd430bca94ddcaaa.diff
LOG: [llvm-jitlink] Avoid repeated hash lookups (NFC) (#130465)
Added:
Modified:
llvm/tools/llvm-jitlink/llvm-jitlink-macho.cpp
Removed:
################################################################################
diff --git a/llvm/tools/llvm-jitlink/llvm-jitlink-macho.cpp b/llvm/tools/llvm-jitlink/llvm-jitlink-macho.cpp
index 2fc56c9fcc72a..07dd3bd38ee61 100644
--- a/llvm/tools/llvm-jitlink/llvm-jitlink-macho.cpp
+++ b/llvm/tools/llvm-jitlink/llvm-jitlink-macho.cpp
@@ -72,14 +72,15 @@ Error registerMachOGraphInfo(Session &S, LinkGraph &G) {
std::lock_guard<std::mutex> Lock(S.M);
auto FileName = sys::path::filename(G.getName());
- if (S.FileInfos.count(FileName)) {
+ auto [It, Inserted] = S.FileInfos.try_emplace(FileName);
+ if (!Inserted) {
return make_error<StringError>("When -check is passed, file names must be "
"distinct (duplicate: \"" +
FileName + "\")",
inconvertibleErrorCode());
}
- auto &FileInfo = S.FileInfos[FileName];
+ auto &FileInfo = It->second;
LLVM_DEBUG({
dbgs() << "Registering MachO file info for \"" << FileName << "\"\n";
});
More information about the llvm-commits
mailing list