mirror of
https://github.com/github/codeql.git
synced 2026-02-08 03:01:10 +01:00
performance improvements
This commit is contained in:
@@ -49,6 +49,7 @@ class AstNode extends TAstNode {
|
||||
/**
|
||||
* Gets the parent in the AST for this node.
|
||||
*/
|
||||
cached
|
||||
AstNode getParent() { result.getAChild(_) = this }
|
||||
|
||||
/**
|
||||
@@ -74,12 +75,14 @@ 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() }
|
||||
Annotation getAnAnnotation() {
|
||||
toQL(this).getParent() = pragma[only_bind_out](toQL(result)).getParent()
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the predicate that contains this AST node.
|
||||
*/
|
||||
pragma[noinline]
|
||||
cached
|
||||
Predicate getEnclosingPredicate() { this = getANodeInPredicate(result) }
|
||||
}
|
||||
|
||||
@@ -2231,6 +2234,8 @@ class Annotation extends TAnnotation, AstNode {
|
||||
/** Gets the node corresponding to the field `name`. */
|
||||
string getName() { result = annot.getName().getValue() }
|
||||
|
||||
override AstNode getParent() { result = AstNode.super.getParent() }
|
||||
|
||||
override AstNode getAChild(string pred) {
|
||||
result = super.getAChild(pred)
|
||||
or
|
||||
|
||||
@@ -126,6 +126,7 @@ private QL::AstNode toGenerateYAML(AST::AstNode n) {
|
||||
/**
|
||||
* Gets the underlying TreeSitter entity for a given AST node.
|
||||
*/
|
||||
cached
|
||||
QL::AstNode toQL(AST::AstNode n) {
|
||||
result = toQLExpr(n)
|
||||
or
|
||||
|
||||
Reference in New Issue
Block a user