[clang-tools-extra] 1bc2f1c - [clang-tidy] Avoid repeated map lookups (NFC) (#127167)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Feb 14 01:33:55 PST 2025
Author: Kazu Hirata
Date: 2025-02-14T01:33:51-08:00
New Revision: 1bc2f1c83f417cdbc11d9cfde780d96aa429ca9f
URL: https://github.com/llvm/llvm-project/commit/1bc2f1c83f417cdbc11d9cfde780d96aa429ca9f
DIFF: https://github.com/llvm/llvm-project/commit/1bc2f1c83f417cdbc11d9cfde780d96aa429ca9f.diff
LOG: [clang-tidy] Avoid repeated map lookups (NFC) (#127167)
Added:
Modified:
clang-tools-extra/clang-tidy/readability/NonConstParameterCheck.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clang-tidy/readability/NonConstParameterCheck.cpp b/clang-tools-extra/clang-tidy/readability/NonConstParameterCheck.cpp
index 43b69a24bdb16..07071a1f6d2fe 100644
--- a/clang-tools-extra/clang-tidy/readability/NonConstParameterCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/NonConstParameterCheck.cpp
@@ -119,13 +119,12 @@ void NonConstParameterCheck::addParm(const ParmVarDecl *Parm) {
T->getPointeeType()->isFloatingType()))
return;
- if (Parameters.find(Parm) != Parameters.end())
+ auto [It, Inserted] = Parameters.try_emplace(Parm);
+ if (!Inserted)
return;
- ParmInfo PI;
- PI.IsReferenced = false;
- PI.CanBeConst = true;
- Parameters[Parm] = PI;
+ It->second.IsReferenced = false;
+ It->second.CanBeConst = true;
}
void NonConstParameterCheck::setReferenced(const DeclRefExpr *Ref) {
More information about the cfe-commits
mailing list