Skip to content

Commit 4459a9b

Browse files
[Sema] Avoid repeated hash lookups (NFC) (#112156)
1 parent d81c2f1 commit 4459a9b

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

clang/lib/Sema/SemaAttr.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -750,12 +750,10 @@ bool Sema::UnifySection(StringRef SectionName, int SectionFlags,
750750
if (auto A = Decl->getAttr<SectionAttr>())
751751
if (A->isImplicit())
752752
PragmaLocation = A->getLocation();
753-
auto SectionIt = Context.SectionInfos.find(SectionName);
754-
if (SectionIt == Context.SectionInfos.end()) {
755-
Context.SectionInfos[SectionName] =
756-
ASTContext::SectionInfo(Decl, PragmaLocation, SectionFlags);
753+
auto [SectionIt, Inserted] = Context.SectionInfos.try_emplace(
754+
SectionName, Decl, PragmaLocation, SectionFlags);
755+
if (Inserted)
757756
return false;
758-
}
759757
// A pre-declared section takes precedence w/o diagnostic.
760758
const auto &Section = SectionIt->second;
761759
if (Section.SectionFlags == SectionFlags ||

0 commit comments

Comments
 (0)