[clang] [Sema] Avoid repeated hash lookups (NFC) (PR #112156)
Kazu Hirata via cfe-commits
cfe-commits at lists.llvm.org
Sun Oct 13 21:02:42 PDT 2024
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/112156
None
>From eeb4bc3b6cf466332b33413441c80291556c3142 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sun, 13 Oct 2024 07:48:45 -0700
Subject: [PATCH] [Sema] Avoid repeated hash lookups (NFC)
---
clang/lib/Sema/SemaAttr.cpp | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
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