Skip to content

Commit 0bfedc7

Browse files
committed
QL: fix performance of the transitive step query
1 parent 02c2603 commit 0bfedc7

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

ql/src/codeql_ql/ast/Ast.qll

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,13 @@ class AstNode extends TAstNode {
7979
* Gets the predicate that contains this AST node.
8080
*/
8181
pragma[noinline]
82-
Predicate getEnclosingPredicate() {
83-
not this instanceof Predicate and
84-
toQL(result) = toQL(this).getParent+()
85-
}
82+
Predicate getEnclosingPredicate() { this = getANodeInPredicate(result) }
83+
}
84+
85+
private AstNode getANodeInPredicate(Predicate pred) {
86+
result = pred.getAChild(_)
87+
or
88+
result = getANodeInPredicate(pred).getAChild(_)
8689
}
8790

8891
/** A toplevel QL program, i.e. a file. */

0 commit comments

Comments
 (0)