From 95681bfad48b508fafec3e3f96ae52287e567dd2 Mon Sep 17 00:00:00 2001 From: Geoffrey White <40627776+geoffw0@users.noreply.github.com> Date: Mon, 9 Mar 2026 15:06:20 +0000 Subject: [PATCH 1/2] Rust: Fix performance issue with File.fromSource. --- rust/ql/lib/codeql/files/FileSystem.qll | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rust/ql/lib/codeql/files/FileSystem.qll b/rust/ql/lib/codeql/files/FileSystem.qll index cfab33b9a440..367f088504b4 100644 --- a/rust/ql/lib/codeql/files/FileSystem.qll +++ b/rust/ql/lib/codeql/files/FileSystem.qll @@ -45,13 +45,16 @@ extensible predicate additionalExternalFile(string relativePath); /** A file. */ class File extends Container, Impl::File { + pragma[nomagic] + private string getRelativePath0() { result = this.getRelativePath() } + /** * Holds if this file was extracted from the source code of the target project * (rather than another location such as inside a dependency). */ predicate fromSource() { exists(ExtractorStep s | s.getAction() = "Extract" and s.getFile() = this) and - not additionalExternalFile(this.getRelativePath()) + not additionalExternalFile(this.getRelativePath0()) } /** From e72c1166640ddddfae86897cf24443da0dc90dd7 Mon Sep 17 00:00:00 2001 From: Geoffrey White <40627776+geoffw0@users.noreply.github.com> Date: Thu, 9 Apr 2026 11:18:25 +0100 Subject: [PATCH 2/2] Rust: Proposed improved solution. --- rust/ql/lib/codeql/files/FileSystem.qll | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rust/ql/lib/codeql/files/FileSystem.qll b/rust/ql/lib/codeql/files/FileSystem.qll index 367f088504b4..93ff7be604e0 100644 --- a/rust/ql/lib/codeql/files/FileSystem.qll +++ b/rust/ql/lib/codeql/files/FileSystem.qll @@ -46,7 +46,7 @@ extensible predicate additionalExternalFile(string relativePath); /** A file. */ class File extends Container, Impl::File { pragma[nomagic] - private string getRelativePath0() { result = this.getRelativePath() } + private predicate isAdditionalExternalFile() { additionalExternalFile(this.getRelativePath()) } /** * Holds if this file was extracted from the source code of the target project @@ -54,7 +54,7 @@ class File extends Container, Impl::File { */ predicate fromSource() { exists(ExtractorStep s | s.getAction() = "Extract" and s.getFile() = this) and - not additionalExternalFile(this.getRelativePath0()) + not this.isAdditionalExternalFile() } /**