[llvm] [llvm-jitlink] Avoid repeated hash lookups (NFC) (PR #129993)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 5 21:58:39 PST 2025
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/129993
None
>From b544608acd4b3c97ddd163c3723bb196857cfef4 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Wed, 5 Mar 2025 09:01:59 -0800
Subject: [PATCH] [llvm-jitlink] Avoid repeated hash lookups (NFC)
---
llvm/tools/llvm-jitlink/llvm-jitlink-elf.cpp | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/llvm/tools/llvm-jitlink/llvm-jitlink-elf.cpp b/llvm/tools/llvm-jitlink/llvm-jitlink-elf.cpp
index 6aa89413b7230..8bd17ebb6317a 100644
--- a/llvm/tools/llvm-jitlink/llvm-jitlink-elf.cpp
+++ b/llvm/tools/llvm-jitlink/llvm-jitlink-elf.cpp
@@ -104,14 +104,15 @@ Error registerELFGraphInfo(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 ELF file info for \"" << FileName << "\"\n";
});
More information about the llvm-commits
mailing list