Skip to content

Commit b2c8f66

Browse files
[Passes] Avoid repeated hash lookups (NFC) (#128828)
1 parent 67d92cf commit b2c8f66

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

llvm/lib/Passes/StandardInstrumentations.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2022,12 +2022,9 @@ DotCfgDiff::DotCfgDiff(StringRef Title, const FuncDataT<DCData> &Before,
20222022
Sink != E; ++Sink) {
20232023
std::string Key = (Label + " " + Sink->getKey().str()).str() + " " +
20242024
BD.getData().getSuccessorLabel(Sink->getKey()).str();
2025-
unsigned C = EdgesMap.count(Key);
2026-
if (C == 0)
2027-
EdgesMap.insert({Key, AfterColour});
2028-
else {
2029-
EdgesMap[Key] = CommonColour;
2030-
}
2025+
auto [It, Inserted] = EdgesMap.try_emplace(Key, AfterColour);
2026+
if (!Inserted)
2027+
It->second = CommonColour;
20312028
}
20322029
}
20332030

0 commit comments

Comments
 (0)