Skip to content

Commit 13546c2

Browse files
[CodeGen] Avoid repeated hash lookups (NFC) (#107736)
1 parent 1d44ecb commit 13546c2

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

clang/lib/CodeGen/CodeGenFunction.h

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,17 +1143,11 @@ class CodeGenFunction : public CodeGenTypeCache {
11431143
/// Copy all the entries in the source map over the corresponding
11441144
/// entries in the destination, which must exist.
11451145
static void copyInto(const DeclMapTy &Src, DeclMapTy &Dest) {
1146-
for (auto &Pair : Src) {
1147-
if (!Pair.second.isValid()) {
1148-
Dest.erase(Pair.first);
1149-
continue;
1150-
}
1151-
1152-
auto I = Dest.find(Pair.first);
1153-
if (I != Dest.end())
1154-
I->second = Pair.second;
1146+
for (auto &[Decl, Addr] : Src) {
1147+
if (!Addr.isValid())
1148+
Dest.erase(Decl);
11551149
else
1156-
Dest.insert(Pair);
1150+
Dest.insert_or_assign(Decl, Addr);
11571151
}
11581152
}
11591153
};

0 commit comments

Comments
 (0)