Skip to content

Commit d098bdc

Browse files
owen-mcsmowton
authored andcommitted
Reintroduce noinlined predicate to fix performance
1 parent ac081dc commit d098bdc

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

ql/lib/semmle/go/Types.qll

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class Type extends @type {
8686
tslit.includesType(this)
8787
) and
8888
(
89-
not i.hasMethod(_, _)
89+
hasNoMethods(i)
9090
or
9191
this.hasMethod(getExampleMethodName(i), _) and
9292
forall(string m, SignatureType t | i.hasMethod(m, t) | this.hasMethod(m, t))
@@ -708,7 +708,7 @@ class TypeSetLiteralType extends @typesetliteraltype, CompositeType {
708708
InterfaceType getInterfaceType() {
709709
this = result.getDirectlyEmbeddedTypeSetLiteral(0) and
710710
not exists(result.getDirectlyEmbeddedTypeSetLiteral(1)) and
711-
not result.hasMethod(_, _) and
711+
hasNoMethods(result) and
712712
not exists(result.getADirectlyEmbeddedInterface())
713713
}
714714

@@ -834,6 +834,10 @@ class InterfaceType extends @interfacetype, CompositeType {
834834
override string toString() { result = "interface type" }
835835
}
836836

837+
// This predicate is needed for performance reasons.
838+
pragma[noinline]
839+
private predicate hasNoMethods(InterfaceType i) { not i.hasMethod(_, _) }
840+
837841
/**
838842
* A basic interface type.
839843
*
@@ -857,7 +861,7 @@ class BasicInterfaceType extends InterfaceType {
857861
* `comparable`. This is done by extending `BasicInterfaceType`.
858862
*/
859863
class EmptyInterfaceType extends BasicInterfaceType {
860-
EmptyInterfaceType() { not this.hasMethod(_, _) }
864+
EmptyInterfaceType() { hasNoMethods(this) }
861865
}
862866

863867
/**

0 commit comments

Comments
 (0)