Skip to content

Commit 3a56b03

Browse files
[IR] Avoid repeated hash lookups (NFC) (#112469)
1 parent 658ff0b commit 3a56b03

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

llvm/lib/IR/LegacyPassManager.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,13 @@ void PMDataManager::emitInstrCountChangedRemark(
104104
[&FunctionToInstrCount](Function &MaybeChangedFn) {
105105
// Update the total module count.
106106
unsigned FnSize = MaybeChangedFn.getInstructionCount();
107-
auto It = FunctionToInstrCount.find(MaybeChangedFn.getName());
108107

109108
// If we created a new function, then we need to add it to the map and
110109
// say that it changed from 0 instructions to FnSize.
111-
if (It == FunctionToInstrCount.end()) {
112-
FunctionToInstrCount[MaybeChangedFn.getName()] =
113-
std::pair<unsigned, unsigned>(0, FnSize);
110+
auto [It, Inserted] = FunctionToInstrCount.try_emplace(
111+
MaybeChangedFn.getName(), 0, FnSize);
112+
if (Inserted)
114113
return;
115-
}
116114
// Insert the new function size into the second member of the pair. This
117115
// tells us whether or not this function changed in size.
118116
It->second.second = FnSize;

0 commit comments

Comments
 (0)