Skip to content

Commit cb729be

Browse files
[CodeGen] Avoid repeated hash lookups (NFC) (#132513)
1 parent 2fa59b3 commit cb729be

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

llvm/lib/CodeGen/GCMetadata.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,10 @@ CollectorMetadataAnalysis::run(Module &M, ModuleAnalysisManager &MAM) {
4141
for (auto &F : M) {
4242
if (F.isDeclaration() || !F.hasGC())
4343
continue;
44-
if (auto GCName = F.getGC(); !Map.contains(GCName))
45-
Map[GCName] = getGCStrategy(GCName);
44+
auto GCName = F.getGC();
45+
auto [It, Inserted] = Map.try_emplace(GCName);
46+
if (Inserted)
47+
It->second = getGCStrategy(GCName);
4648
}
4749
return R;
4850
}

0 commit comments

Comments
 (0)