Skip to content

Commit d4a4536

Browse files
committed
Improve performance of compare view using Promise.all
1 parent ab1966a commit d4a4536

File tree

2 files changed

+33
-33
lines changed

2 files changed

+33
-33
lines changed

extensions/ql-vscode/src/compare/compare-view.ts

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@ export class CompareView extends AbstractWebview<
6868
to: CompletedLocalQueryInfo,
6969
selectedResultSetName?: string,
7070
) {
71-
const fromSchemas = await this.cliServer.bqrsInfo(
72-
from.completedQuery.query.resultsPaths.resultsPath,
73-
);
74-
const toSchemas = await this.cliServer.bqrsInfo(
75-
to.completedQuery.query.resultsPaths.resultsPath,
76-
);
71+
const [fromSchemas, toSchemas] = await Promise.all([
72+
this.cliServer.bqrsInfo(
73+
from.completedQuery.query.resultsPaths.resultsPath,
74+
),
75+
this.cliServer.bqrsInfo(to.completedQuery.query.resultsPaths.resultsPath),
76+
]);
7777

7878
const [fromSchemaNames, toSchemaNames] = await Promise.all([
7979
getResultSetNames(
@@ -296,16 +296,18 @@ export class CompareView extends AbstractWebview<
296296
fromResultSetName: string,
297297
toResultSetName: string,
298298
): Promise<RawQueryCompareResult> {
299-
const fromResultSet = await this.getResultSet(
300-
fromInfo.schemas,
301-
fromResultSetName,
302-
from.completedQuery.query.resultsPaths.resultsPath,
303-
);
304-
const toResultSet = await this.getResultSet(
305-
toInfo.schemas,
306-
toResultSetName,
307-
to.completedQuery.query.resultsPaths.resultsPath,
308-
);
299+
const [fromResultSet, toResultSet] = await Promise.all([
300+
this.getResultSet(
301+
fromInfo.schemas,
302+
fromResultSetName,
303+
from.completedQuery.query.resultsPaths.resultsPath,
304+
),
305+
this.getResultSet(
306+
toInfo.schemas,
307+
toResultSetName,
308+
to.completedQuery.query.resultsPaths.resultsPath,
309+
),
310+
]);
309311

310312
return resultsDiff(fromResultSet, toResultSet);
311313
}

extensions/ql-vscode/src/compare/interpreted-results.ts

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,6 @@ export async function compareInterpretedResults(
2525
fromQuery: CompletedLocalQueryInfo,
2626
toQuery: CompletedLocalQueryInfo,
2727
): Promise<InterpretedQueryCompareResult> {
28-
const fromResultSet = await getInterpretedResults(
29-
fromQuery.completedQuery.query.resultsPaths.interpretedResultsPath,
30-
);
31-
32-
const toResultSet = await getInterpretedResults(
33-
toQuery.completedQuery.query.resultsPaths.interpretedResultsPath,
34-
);
35-
36-
if (!fromResultSet || !toResultSet) {
37-
throw new Error(
38-
"Could not find interpreted results for one or both queries.",
39-
);
40-
}
41-
4228
const database = databaseManager.findDatabaseItem(
4329
Uri.parse(toQuery.initialInfo.databaseInfo.databaseUri),
4430
);
@@ -48,9 +34,21 @@ export async function compareInterpretedResults(
4834
);
4935
}
5036

51-
const sourceLocationPrefix = await database.getSourceLocationPrefix(
52-
cliServer,
53-
);
37+
const [fromResultSet, toResultSet, sourceLocationPrefix] = await Promise.all([
38+
getInterpretedResults(
39+
fromQuery.completedQuery.query.resultsPaths.interpretedResultsPath,
40+
),
41+
getInterpretedResults(
42+
toQuery.completedQuery.query.resultsPaths.interpretedResultsPath,
43+
),
44+
database.getSourceLocationPrefix(cliServer),
45+
]);
46+
47+
if (!fromResultSet || !toResultSet) {
48+
throw new Error(
49+
"Could not find interpreted results for one or both queries.",
50+
);
51+
}
5452

5553
const fromResults = fromResultSet.runs[0].results;
5654
const toResults = toResultSet.runs[0].results;

0 commit comments

Comments
 (0)