mirror of
https://github.com/github/codeql.git
synced 2026-02-08 11:11:06 +01:00
fix performance
This commit is contained in:
@@ -70,7 +70,10 @@ class AstNode extends TAstNode {
|
||||
predicate hasAnnotation(string name) { this.getAnAnnotation().getName() = name }
|
||||
|
||||
/** Gets an annotation of this AST node. */
|
||||
Annotation getAnAnnotation() { toQL(this).getParent() = toQL(result).getParent() }
|
||||
cached
|
||||
Annotation getAnAnnotation() {
|
||||
toQL(this).getParent() = pragma[only_bind_out](toQL(result)).getParent()
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the predicate that contains this AST node.
|
||||
|
||||
@@ -148,14 +148,16 @@ private predicate resolveSelectionName(Import imp, ContainerOrModule m, int i) {
|
||||
|
||||
cached
|
||||
private module Cached {
|
||||
// TODO: Use `AstNode::getParent` once it is total
|
||||
private QL::AstNode parent(QL::AstNode n) {
|
||||
result = n.getParent() and
|
||||
not n instanceof QL::Module
|
||||
}
|
||||
|
||||
private Module getEnclosingModule0(AstNode n) {
|
||||
AstNodes::toQL(result) = parent*(AstNodes::toQL(n).getParent())
|
||||
not n instanceof Module and
|
||||
(
|
||||
n = result.getAChild(_)
|
||||
or
|
||||
exists(AstNode prev |
|
||||
result = getEnclosingModule0(prev) and
|
||||
n = prev.getAChild(_)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
cached
|
||||
|
||||
Reference in New Issue
Block a user