Skip to content

Commit ea4ee78

Browse files
committed
Use a precomputed map
1 parent f818aaa commit ea4ee78

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

src/ctest.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1923,15 +1923,17 @@ export class CTestDriver implements vscode.Disposable {
19231923
let overallSuccess = true;
19241924
for (const [project, targets] of foundTarget) {
19251925
const execTargets = await project.executableTargets;
1926+
// Precompute a lookup map from normalized executable path to target name
1927+
const execPathToName = new Map<string, string>();
1928+
for (const t of execTargets) {
1929+
execPathToName.set(util.platformNormalizePath(t.path), t.name);
1930+
}
19261931
const accumulatedTestList: vscode.TestItem[] = [];
19271932
const accumulatedTargets: string[] = [];
19281933
let success: boolean = true;
1929-
for (const [targetPath, testList] of targets) {
1930-
// Look up the CMake target name from executable targets by matching
1931-
// the executable path. Using path.relative() uses the executable instead of the target name
1934+
for (const [targetPath, testList] of targets) {
19321935
const normalizedTargetPath = util.platformNormalizePath(targetPath);
1933-
const execTarget = execTargets.find(t => util.platformNormalizePath(t.path) === normalizedTargetPath);
1934-
accumulatedTargets.push(execTarget ? execTarget.name : path.parse(targetPath).name);
1936+
accumulatedTargets.push(execPathToName.get(normalizedTargetPath) ?? path.parse(targetPath).name);
19351937
accumulatedTestList.push(...testList);
19361938
}
19371939
try {

0 commit comments

Comments
 (0)