[llvm] [IR] Avoid repeated hash lookups (NFC) (PR #108485)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 12 20:38:40 PDT 2024


https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/108485

None

>From 129960593c85c3024e420fe91f54b0a6c7138413 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Thu, 12 Sep 2024 01:00:58 -0700
Subject: [PATCH] [IR] Avoid repeated hash lookups (NFC)

---
 llvm/lib/IR/LLVMContext.cpp | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/llvm/lib/IR/LLVMContext.cpp b/llvm/lib/IR/LLVMContext.cpp
index 194c7e7581cfbb..c0fee93a233808 100644
--- a/llvm/lib/IR/LLVMContext.cpp
+++ b/llvm/lib/IR/LLVMContext.cpp
@@ -331,13 +331,7 @@ void LLVMContext::getSyncScopeNames(SmallVectorImpl<StringRef> &SSNs) const {
 }
 
 void LLVMContext::setGC(const Function &Fn, std::string GCName) {
-  auto It = pImpl->GCNames.find(&Fn);
-
-  if (It == pImpl->GCNames.end()) {
-    pImpl->GCNames.insert(std::make_pair(&Fn, std::move(GCName)));
-    return;
-  }
-  It->second = std::move(GCName);
+  pImpl->GCNames[&Fn] = std::move(GCName);
 }
 
 const std::string &LLVMContext::getGC(const Function &Fn) {



More information about the llvm-commits mailing list