Merge pull request #19186 from github/tausbn/actions-fix-gettargetpath-performance

Actions: Fix bad performance in `getTargetPath`
This commit is contained in:
Taus
2025-04-02 12:53:56 +02:00
committed by GitHub

View File

@@ -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("/%")
}
}