Skip to content

Commit 74cba90

Browse files
committed
Optimise join orders
1 parent d04a0f4 commit 74cba90

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

go/ql/lib/semmle/go/AST.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ class AstNode extends @node, Locatable {
7979
}
8080

8181
/** Gets the innermost function definition to which this AST node belongs, if any. */
82+
pragma[nomagic]
8283
FuncDef getEnclosingFunction() { result = this.getParent().parentInSameFunction*() }
8384

8485
/**

go/ql/lib/semmle/go/Scopes.qll

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,13 @@ class Function extends ValueEntity, @functionobject {
479479
ResultVariable getAResult() { result = this.getResult(_) }
480480
}
481481

482+
pragma[inline_late]
483+
bindingset[m]
484+
private Type implementsIncludingInterfaceMethodsCand(Method m, string mname) {
485+
result.implements(m.getReceiverType().getUnderlyingType()) and
486+
mname = m.getName()
487+
}
488+
482489
/**
483490
* A method, that is, a function with a receiver variable, or a function declared in an interface.
484491
*
@@ -580,9 +587,14 @@ class Method extends Function {
580587
predicate implementsIncludingInterfaceMethods(Method m) {
581588
this = m
582589
or
583-
exists(Type t |
584-
this = t.getMethod(m.getName()) and
585-
t.implements(m.getReceiverType().getUnderlyingType())
590+
// Take all methods
591+
// Get receiver type then underlying type ==> [method, recvutype]
592+
// Map through Type.implements ==> [method, candtype]
593+
// Get method name ==> [mname, candtype]
594+
// Get corresponding method
595+
exists(Type t, string mname |
596+
t = implementsIncludingInterfaceMethodsCand(m, mname) and
597+
this = t.getMethod(mname)
586598
)
587599
}
588600

0 commit comments

Comments
 (0)