[clang] 4459a9b - [Sema] Avoid repeated hash lookups (NFC) (#112156)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 14 06:54:35 PDT 2024
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 ||
More information about the cfe-commits
mailing list