mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
Merge pull request #19186 from github/tausbn/actions-fix-gettargetpath-performance
Actions: Fix bad performance in `getTargetPath`
This commit is contained in:
@@ -424,14 +424,24 @@ module Make<InputSig Input> {
|
||||
* Gets the absolute path of the file included by this directive.
|
||||
*/
|
||||
private string getTargetPath() {
|
||||
exists(string path | path = this.getValue() |
|
||||
if path.matches("/%")
|
||||
then result = path
|
||||
else
|
||||
result =
|
||||
this.getDocument().getLocation().getFile().getParentContainer().getAbsolutePath() + "/" +
|
||||
path
|
||||
)
|
||||
result = this.getAbsolutePath()
|
||||
or
|
||||
result =
|
||||
this.getDocument().getLocation().getFile().getParentContainer().getAbsolutePath() + "/" +
|
||||
this.getRelativePath()
|
||||
}
|
||||
|
||||
/** Join-order helper for `getTargetPath`. Gets the path but only if it is an absolute path. */
|
||||
private string getAbsolutePath() {
|
||||
result = this.getValue() and
|
||||
result.matches("/%")
|
||||
}
|
||||
|
||||
/** Join-order helper for `getTargetPath`. Gets the path, but only if it is a relative path. */
|
||||
pragma[noinline]
|
||||
private string getRelativePath() {
|
||||
result = this.getValue() and
|
||||
not result.matches("/%")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user