From 62355f3f0ee6c36d3ec5ebc6c143ee4320704e5b Mon Sep 17 00:00:00 2001 From: Erik Krogh Kristensen Date: Fri, 15 Oct 2021 18:47:54 +0200 Subject: [PATCH] fix performance of the transitive step query --- ql/src/codeql_ql/ast/Ast.qll | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ql/src/codeql_ql/ast/Ast.qll b/ql/src/codeql_ql/ast/Ast.qll index bb819b59a53..ed776d07a1c 100644 --- a/ql/src/codeql_ql/ast/Ast.qll +++ b/ql/src/codeql_ql/ast/Ast.qll @@ -79,10 +79,13 @@ class AstNode extends TAstNode { * Gets the predicate that contains this AST node. */ pragma[noinline] - Predicate getEnclosingPredicate() { - not this instanceof Predicate and - toQL(result) = toQL(this).getParent+() - } + Predicate getEnclosingPredicate() { this = getANodeInPredicate(result) } +} + +private AstNode getANodeInPredicate(Predicate pred) { + result = pred.getAChild(_) + or + result = getANodeInPredicate(pred).getAChild(_) } /** A toplevel QL program, i.e. a file. */