[clang] [Analysis] Avoid repeated hash lookups (NFC) (PR #108674)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 13 20:23:54 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-analysis
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/108674.diff
1 Files Affected:
- (modified) clang/include/clang/Analysis/Analyses/ExprMutationAnalyzer.h (+4-8)
``````````diff
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();
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/108674
More information about the cfe-commits
mailing list