Skip to content

Commit 5dca89c

Browse files
[Analysis] Avoid repeated hash lookups (NFC) (#112297)
1 parent a061d4d commit 5dca89c

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

llvm/include/llvm/Analysis/RegionInfoImpl.h

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -338,14 +338,11 @@ template <class Tr>
338338
typename Tr::RegionNodeT *RegionBase<Tr>::getBBNode(BlockT *BB) const {
339339
assert(contains(BB) && "Can get BB node out of this region!");
340340

341-
typename BBNodeMapT::const_iterator at = BBNodeMap.find(BB);
342-
343-
if (at == BBNodeMap.end()) {
341+
auto [at, Inserted] = BBNodeMap.try_emplace(BB);
342+
if (Inserted) {
344343
auto Deconst = const_cast<RegionBase<Tr> *>(this);
345-
typename BBNodeMapT::value_type V = {
346-
BB,
347-
std::make_unique<RegionNodeT>(static_cast<RegionT *>(Deconst), BB)};
348-
at = BBNodeMap.insert(std::move(V)).first;
344+
at->second =
345+
std::make_unique<RegionNodeT>(static_cast<RegionT *>(Deconst), BB);
349346
}
350347
return at->second.get();
351348
}

0 commit comments

Comments
 (0)