[clang] 22aeec3 - [Analysis] Avoid repeated hash lookups (NFC) (#108674)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 13 23:12:48 PDT 2024
Author: Kazu Hirata
Date: 2024-09-13T23:12:44-07:00
New Revision: 22aeec31b9833df4428f70cb11f789ad203178d8
URL: https://github.com/llvm/llvm-project/commit/22aeec31b9833df4428f70cb11f789ad203178d8
DIFF: https://github.com/llvm/llvm-project/commit/22aeec31b9833df4428f70cb11f789ad203178d8.diff
LOG: [Analysis] Avoid repeated hash lookups (NFC) (#108674)
Added:
Modified:
clang/include/clang/Analysis/Analyses/ExprMutationAnalyzer.h
Removed:
################################################################################
diff --git a/clang/include/clang/Analysis/Analyses/ExprMutationAnalyzer.h b/clang/include/clang/Analysis/Analyses/ExprMutationAnalyzer.h
index 117173ba9a0958..b7b84852168e2e 100644
--- a/clang/include/clang/Analysis/Analyses/ExprMutationAnalyzer.h
+++ b/clang/include/clang/Analysis/Analyses/ExprMutationAnalyzer.h
@@ -118,14 +118,10 @@ class FunctionParmMutationAnalyzer {
static FunctionParmMutationAnalyzer *
getFunctionParmMutationAnalyzer(const FunctionDecl &Func, ASTContext &Context,
ExprMutationAnalyzer::Memoized &Memorized) {
- auto it = Memorized.FuncParmAnalyzer.find(&Func);
- if (it == Memorized.FuncParmAnalyzer.end())
- it =
- Memorized.FuncParmAnalyzer
- .try_emplace(&Func, std::unique_ptr<FunctionParmMutationAnalyzer>(
- new FunctionParmMutationAnalyzer(
- Func, Context, Memorized)))
- .first;
+ auto [it, Inserted] = Memorized.FuncParmAnalyzer.try_emplace(&Func);
+ if (Inserted)
+ it->second = std::unique_ptr<FunctionParmMutationAnalyzer>(
+ new FunctionParmMutationAnalyzer(Func, Context, Memorized));
return it->getSecond().get();
}
More information about the cfe-commits
mailing list