Skip to content

Commit 013c7ba

Browse files
[CodeGen] Use DenseMap::try_emplace (NFC) (llvm#140430)
We can simplify the code with DenseMap::try_emplace and structured binding. Note that DenseMap::try_emplace default-constructs the value if omitted.
1 parent dd702b3 commit 013c7ba

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

clang/lib/CodeGen/MicrosoftCXXABI.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1818,9 +1818,7 @@ llvm::GlobalVariable *MicrosoftCXXABI::getAddrOfVTable(const CXXRecordDecl *RD,
18181818
// VFTablesMap, thus a simple zero check is not sufficient.
18191819

18201820
VFTableIdTy ID(RD, VPtrOffset);
1821-
VTablesMapTy::iterator I;
1822-
bool Inserted;
1823-
std::tie(I, Inserted) = VTablesMap.insert(std::make_pair(ID, nullptr));
1821+
auto [I, Inserted] = VTablesMap.try_emplace(ID);
18241822
if (!Inserted)
18251823
return I->second;
18261824

@@ -2036,10 +2034,7 @@ const VBTableGlobals &
20362034
MicrosoftCXXABI::enumerateVBTables(const CXXRecordDecl *RD) {
20372035
// At this layer, we can key the cache off of a single class, which is much
20382036
// easier than caching each vbtable individually.
2039-
llvm::DenseMap<const CXXRecordDecl*, VBTableGlobals>::iterator Entry;
2040-
bool Added;
2041-
std::tie(Entry, Added) =
2042-
VBTablesMap.insert(std::make_pair(RD, VBTableGlobals()));
2037+
auto [Entry, Added] = VBTablesMap.try_emplace(RD);
20432038
VBTableGlobals &VBGlobals = Entry->second;
20442039
if (!Added)
20452040
return VBGlobals;

0 commit comments

Comments
 (0)