diff options
author | Kazu Hirata <kazu@google.com> | 2025-07-17 07:23:07 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-07-17 07:23:07 -0700 |
commit | 577585198637fc2ced2a4fdf20f91c58fb74c717 (patch) | |
tree | 8f245fdb43861e0b2ff58bc74d8c1aa3453b5f4a /llvm/lib | |
parent | 73e8ada540acbd60f916ef4b0a5a2b454c8ece44 (diff) | |
download | llvm-577585198637fc2ced2a4fdf20f91c58fb74c717.zip llvm-577585198637fc2ced2a4fdf20f91c58fb74c717.tar.gz llvm-577585198637fc2ced2a4fdf20f91c58fb74c717.tar.bz2 |
[llvm] Use *Map::try_emplace (NFC) (#149257)
- try_emplace(Key) is shorter than insert({Key, nullptr}).
- try_emplace performs value initialization without value parameters.
- We overwrite values on successful insertion anyway.
While we are at it, this patch simplifies the code with structured
binding.
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/MC/MCContext.cpp | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/llvm/lib/MC/MCContext.cpp b/llvm/lib/MC/MCContext.cpp index 070be62..12b3fba 100644 --- a/llvm/lib/MC/MCContext.cpp +++ b/llvm/lib/MC/MCContext.cpp @@ -734,9 +734,8 @@ MCSectionGOFF *MCContext::getGOFFSection(SectionKind Kind, StringRef Name, UniqueName.append("/").append(P->getName()); } // Do the lookup. If we don't have a hit, return a new section. - auto IterBool = GOFFUniquingMap.insert(std::make_pair(UniqueName, nullptr)); - auto Iter = IterBool.first; - if (!IterBool.second) + auto [Iter, Inserted] = GOFFUniquingMap.try_emplace(UniqueName); + if (!Inserted) return Iter->second; StringRef CachedName = StringRef(Iter->first.c_str(), Name.size()); |