[clang] 28733ed - [Analysis] Avoid repeated hash lookups (NFC) (#110949)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 3 08:28:21 PDT 2024
Author: Kazu Hirata
Date: 2024-10-03T08:28:18-07:00
New Revision: 28733ed686c4ca54042d6a9b8ae318c8f3b7b287
URL: https://github.com/llvm/llvm-project/commit/28733ed686c4ca54042d6a9b8ae318c8f3b7b287
DIFF: https://github.com/llvm/llvm-project/commit/28733ed686c4ca54042d6a9b8ae318c8f3b7b287.diff
LOG: [Analysis] Avoid repeated hash lookups (NFC) (#110949)
Added:
Modified:
clang/lib/Analysis/ExprMutationAnalyzer.cpp
Removed:
################################################################################
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