mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
JavaScript: Fix performance regression in IncorrectSuffixCheck.
This commit is contained in:
@@ -30,17 +30,26 @@ class IndexOfCall extends DataFlow::MethodCallNode {
|
||||
result = getArgument(0)
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if `recv` is the local source of the receiver of this call, and `m`
|
||||
* is the name of the invoked method.
|
||||
*/
|
||||
private predicate receiverAndMethodName(DataFlow::Node recv, string m) {
|
||||
this.getReceiver().getALocalSource() = recv and
|
||||
this.getMethodName() = m
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an `indexOf` call with the same receiver, argument, and method name, including this call itself.
|
||||
*/
|
||||
IndexOfCall getAnEquivalentIndexOfCall() {
|
||||
result.getReceiver().getALocalSource() = this.getReceiver().getALocalSource() and
|
||||
(
|
||||
exists(DataFlow::Node recv, string m |
|
||||
this.receiverAndMethodName(recv, m) and result.receiverAndMethodName(recv, m)
|
||||
|
|
||||
result.getArgument(0).getALocalSource() = this.getArgument(0).getALocalSource()
|
||||
or
|
||||
result.getArgument(0).getStringValue() = this.getArgument(0).getStringValue()
|
||||
) and
|
||||
result.getMethodName() = this.getMethodName()
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user