Skip to content

Commit 52bc67c

Browse files
committed
[NFC] Place lambda out of loop
1 parent 7b7ba72 commit 52bc67c

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

clang-tools-extra/clang-tidy/modernize/UseStructuredBindingCheck.cpp

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,22 @@ static bool matchNVarDeclStartingWith(
4444
const DeclStmt *EndDS = nullptr;
4545
size_t N = InnerMatchers.size();
4646
size_t Count = 0;
47+
48+
auto Matches = [&](const Decl *VD) {
49+
// We don't want redundant decls in DeclStmt.
50+
if (Count == N)
51+
return false;
52+
53+
if (const auto *Var = dyn_cast<VarDecl>(VD);
54+
Var && InnerMatchers[Backwards ? N - Count - 1 : Count].matches(
55+
*Var, Finder, Builder)) {
56+
++Count;
57+
return true;
58+
}
59+
60+
return false;
61+
};
62+
4763
for (; Iter != EndIter; ++Iter) {
4864
EndDS = dyn_cast<DeclStmt>(*Iter);
4965
if (!EndDS)
@@ -52,21 +68,6 @@ static bool matchNVarDeclStartingWith(
5268
if (!BeginDS)
5369
BeginDS = EndDS;
5470

55-
auto Matches = [&](const Decl *VD) {
56-
// We don't want redundant decls in DeclStmt.
57-
if (Count == N)
58-
return false;
59-
60-
if (const auto *Var = dyn_cast<VarDecl>(VD);
61-
Var && InnerMatchers[Backwards ? N - Count - 1 : Count].matches(
62-
*Var, Finder, Builder)) {
63-
++Count;
64-
return true;
65-
}
66-
67-
return false;
68-
};
69-
7071
if (Backwards) {
7172
for (const auto *VD : llvm::reverse(EndDS->decls())) {
7273
if (!Matches(VD))

0 commit comments

Comments
 (0)