Skip to content

Commit 9b93c9a

Browse files
[PassManager] Simplify code with DenseMap::try_emplace (NFC) (#140402)
We can simplify the code with DenseMap::try_emplace and structured binding. Note that DenseMap::try_emplace default-constructs the value if omitted.
1 parent fadaf0c commit 9b93c9a

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

llvm/include/llvm/IR/PassManagerImpl.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,7 @@ template <typename IRUnitT, typename... ExtraArgTs>
136136
inline typename AnalysisManager<IRUnitT, ExtraArgTs...>::ResultConceptT &
137137
AnalysisManager<IRUnitT, ExtraArgTs...>::getResultImpl(
138138
AnalysisKey *ID, IRUnitT &IR, ExtraArgTs... ExtraArgs) {
139-
typename AnalysisResultMapT::iterator RI;
140-
bool Inserted;
141-
std::tie(RI, Inserted) = AnalysisResults.insert(std::make_pair(
142-
std::make_pair(ID, &IR), typename AnalysisResultListT::iterator()));
139+
auto [RI, Inserted] = AnalysisResults.try_emplace(std::make_pair(ID, &IR));
143140

144141
// If we don't have a cached result for this function, look up the pass and
145142
// run it to produce a result, which we then add to the cache.

0 commit comments

Comments
 (0)