[clang] [Analysis] Avoid repeated hash lookups (NFC) (PR #110949)
Kazu Hirata via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 2 20:13:42 PDT 2024
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/110949
None
>From 0e4235061e3f668c0d1b86cc993eada3ca7efac7 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Wed, 2 Oct 2024 07:00:45 -0700
Subject: [PATCH] [Analysis] Avoid repeated hash lookups (NFC)
---
clang/lib/Analysis/ExprMutationAnalyzer.cpp | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/clang/lib/Analysis/ExprMutationAnalyzer.cpp b/clang/lib/Analysis/ExprMutationAnalyzer.cpp
index 6d726ae44104ed..5a95ef36d05024 100644
--- a/clang/lib/Analysis/ExprMutationAnalyzer.cpp
+++ b/clang/lib/Analysis/ExprMutationAnalyzer.cpp
@@ -231,12 +231,11 @@ ExprMutationAnalyzer::Analyzer::findPointeeMutation(const Decl *Dec) {
const Stmt *ExprMutationAnalyzer::Analyzer::findMutationMemoized(
const Expr *Exp, llvm::ArrayRef<MutationFinder> Finders,
Memoized::ResultMap &MemoizedResults) {
- const auto Memoized = MemoizedResults.find(Exp);
- if (Memoized != MemoizedResults.end())
+ auto [Memoized, Inserted] = MemoizedResults.try_emplace(Exp);
+ if (!Inserted)
return Memoized->second;
// Assume Exp is not mutated before analyzing Exp.
- MemoizedResults[Exp] = nullptr;
if (isUnevaluated(Exp))
return nullptr;
More information about the cfe-commits
mailing list