Author: Kazu Hirata
Date: 2024-10-14T06:54:32-07:00
New Revision: 4459a9b6436d9443944da9a086bd42724334afa0

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

LOG: [Sema] Avoid repeated hash lookups (NFC) (#112156)

Added: 
    

Modified: 
    clang/lib/Sema/SemaAttr.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Sema/SemaAttr.cpp b/clang/lib/Sema/SemaAttr.cpp
index cf2a5a622a3a4d..68a8dfaf1f6183 100644
--- a/clang/lib/Sema/SemaAttr.cpp
+++ b/clang/lib/Sema/SemaAttr.cpp
@@ -750,12 +750,10 @@ bool Sema::UnifySection(StringRef SectionName, int 
SectionFlags,
   if (auto A = Decl->getAttr<SectionAttr>())
     if (A->isImplicit())
       PragmaLocation = A->getLocation();
-  auto SectionIt = Context.SectionInfos.find(SectionName);
-  if (SectionIt == Context.SectionInfos.end()) {
-    Context.SectionInfos[SectionName] =
-        ASTContext::SectionInfo(Decl, PragmaLocation, SectionFlags);
+  auto [SectionIt, Inserted] = Context.SectionInfos.try_emplace(
+      SectionName, Decl, PragmaLocation, SectionFlags);
+  if (Inserted)
     return false;
-  }
   // A pre-declared section takes precedence w/o diagnostic.
   const auto &Section = SectionIt->second;
   if (Section.SectionFlags == SectionFlags ||


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to