Skip to content

Commit 74e7061

Browse files
author
Max Schaefer
committed
JavaScript: Fix performance regression in MixedStaticInstanceThisAccess.
1 parent 733c7b0 commit 74e7061

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

javascript/ql/src/Declarations/MixedStaticInstanceThisAccess.ql

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,33 +17,31 @@ predicate hasMethod(ClassDefinition base, string name, MethodDefinition m) {
1717
}
1818

1919
/**
20-
* Holds if `access` is in`fromMethod`, and it references `toMethod` through `this`.
20+
* Holds if `access` is in`fromMethod`, and it references `toMethod` through `this`,
21+
* where `fromMethod` and `toMethod` are of kind `fromKind` and `toKind`, respectively.
2122
*/
22-
predicate isLocalMethodAccess(PropAccess access, MethodDefinition fromMethod, MethodDefinition toMethod) {
23-
hasMethod(fromMethod.getDeclaringClass(), access.getPropertyName(), toMethod) and
24-
access.getEnclosingFunction() = fromMethod.getBody() and
25-
access.getBase() instanceof ThisExpr
23+
predicate isLocalMethodAccess(PropAccess access, MethodDefinition fromMethod, string fromKind,
24+
MethodDefinition toMethod, string toKind) {
25+
hasMethod(fromMethod.getDeclaringClass(), access.getPropertyName(), toMethod) and
26+
access.getEnclosingFunction() = fromMethod.getBody() and
27+
access.getBase() instanceof ThisExpr and
28+
fromKind = getKind(fromMethod) and
29+
toKind = getKind(toMethod)
2630
}
2731

2832
string getKind(MethodDefinition m) {
29-
if m.isStatic() then result = "static" else result = "instance"
33+
if m.isStatic() then result = "static" else result = "instance"
3034
}
3135

3236
from PropAccess access, MethodDefinition fromMethod, MethodDefinition toMethod, string fromKind, string toKind
3337
where
34-
isLocalMethodAccess(access, fromMethod, toMethod) and
35-
fromKind = getKind(fromMethod) and
36-
toKind = getKind(toMethod) and
38+
isLocalMethodAccess(access, fromMethod, fromKind, toMethod, toKind) and
3739
toKind != fromKind and
38-
not toKind = fromKind and
3940

4041
// exceptions
4142
not (
4243
// the class has a second member with the same name and the right kind
43-
exists (MethodDefinition toMethodWithSameKind |
44-
isLocalMethodAccess(access, fromMethod, toMethodWithSameKind) and
45-
fromKind = getKind(toMethodWithSameKind)
46-
)
44+
isLocalMethodAccess(access, fromMethod, _, _, fromKind)
4745
or
4846
// there is a dynamically assigned second member with the same name and the right kind
4947
exists (AnalyzedPropertyWrite apw, AbstractClass declaringClass, AbstractValue base |

0 commit comments

Comments
 (0)