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

via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 12 20:39:09 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-ir

Author: Kazu Hirata (kazutakahirata)

<details>
<summary>Changes</summary>



---
Full diff: https://github.com/llvm/llvm-project/pull/108485.diff


1 Files Affected:

- (modified) llvm/lib/IR/LLVMContext.cpp (+1-7) 


``````````diff
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) {

``````````

</details>


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


More information about the llvm-commits mailing list