Skip to content

Commit 0aded15

Browse files
committed
Improve NestedLoopsSameVariable query performance
1 parent 9854b95 commit 0aded15

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

csharp/ql/src/Likely Bugs/NestedLoopsSameVariable.ql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ class NestedForConditions extends SC::StructuralComparisonConfiguration {
2828
}
2929

3030
private predicate hasChild(Stmt outer, Element child) {
31-
outer = child.getParent()
31+
outer = child.getParent() and
32+
(outer instanceof ForStmt or outer = any(ForStmt f).getBody())
3233
or
3334
hasChild(outer, child.getParent())
3435
}

0 commit comments

Comments
 (0)