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

via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 12 22:40:58 PDT 2024


Author: Kazu Hirata
Date: 2024-09-12T22:40:55-07:00
New Revision: a4d74644ba716d8c404720ccda90d42acee91917

URL: https://github.com/llvm/llvm-project/commit/a4d74644ba716d8c404720ccda90d42acee91917
DIFF: https://github.com/llvm/llvm-project/commit/a4d74644ba716d8c404720ccda90d42acee91917.diff

LOG: [IR] Avoid repeated hash lookups (NFC) (#108485)

Added: 
    

Modified: 
    llvm/lib/IR/LLVMContext.cpp

Removed: 
    


################################################################################
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