Skip to content

Commit 8a9e9a8

Browse files
[Analysis] Avoid repeated hash lookups (NFC) (#110397)
1 parent 5c811cc commit 8a9e9a8

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

llvm/lib/Analysis/InlineCost.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -504,8 +504,9 @@ class CallAnalyzer : public InstVisitor<CallAnalyzer, bool> {
504504
InlineResult analyze();
505505

506506
std::optional<Constant *> getSimplifiedValue(Instruction *I) {
507-
if (SimplifiedValues.contains(I))
508-
return SimplifiedValues[I];
507+
auto It = SimplifiedValues.find(I);
508+
if (It != SimplifiedValues.end())
509+
return It->second;
509510
return std::nullopt;
510511
}
511512

@@ -1129,8 +1130,9 @@ class InlineCostCallAnalyzer final : public CallAnalyzer {
11291130
void print(raw_ostream &OS);
11301131

11311132
std::optional<InstructionCostDetail> getCostDetails(const Instruction *I) {
1132-
if (InstructionCostDetailMap.contains(I))
1133-
return InstructionCostDetailMap[I];
1133+
auto It = InstructionCostDetailMap.find(I);
1134+
if (It != InstructionCostDetailMap.end())
1135+
return It->second;
11341136
return std::nullopt;
11351137
}
11361138

0 commit comments

Comments
 (0)