Skip to content

Commit 16c0652

Browse files
authored
Merge pull request #666 from hvitved/csharp/useless-upcast-performance
C#: Improve performance of `cs/useless-upcast`
2 parents e194021 + 7422947 commit 16c0652

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

csharp/ql/src/Language Abuse/UselessUpcast.ql

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,9 @@ class ExplicitUpcast extends ExplicitCast {
118118
}
119119

120120
pragma [nomagic]
121-
private predicate isDisambiguatingStaticCall0(StaticCall c, StaticCallable target, ValueOrRefType t) {
121+
private predicate isDisambiguatingStaticCall0(StaticCall c, StaticCallable target, string name, ValueOrRefType t) {
122122
this.isArgument(c, target) and
123+
name = target.getName() and
123124
(
124125
t = c.(QualifiableExpr).getQualifier().getType()
125126
or
@@ -131,9 +132,9 @@ class ExplicitUpcast extends ExplicitCast {
131132
/** Holds if this upcast may be used to disambiguate the target of a static call. */
132133
pragma [nomagic]
133134
private predicate isDisambiguatingStaticCall(StaticCallable other, int args) {
134-
exists(StaticCall c, StaticCallable target, ValueOrRefType t |
135-
this.isDisambiguatingStaticCall0(c, target, t) |
136-
hasStaticCallable(t, other, target.getName()) and
135+
exists(StaticCall c, StaticCallable target, ValueOrRefType t, string name |
136+
this.isDisambiguatingStaticCall0(c, target, name, t) |
137+
hasStaticCallable(t, other, name) and
137138
args = c.getNumberOfArguments() and
138139
other != target
139140
)

0 commit comments

Comments
 (0)