Skip to content

Commit d07b358

Browse files
committed
fix(perf): plumb symbolsOnly through parseFilesWasmInline to skip analysis visitors
1 parent 84e1a5f commit d07b358

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

src/domain/parser.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1198,11 +1198,16 @@ const INLINE_BACKFILL_THRESHOLD = 16;
11981198
*
11991199
* Returns symbols with `_tree` set so `runAnalyses` can run AST/CFG/dataflow
12001200
* visitors via the unified walker (mirrors how WASM-engine results behaved
1201-
* before the worker pool was introduced).
1201+
* before the worker pool was introduced), unless `symbolsOnly` is true — in
1202+
* that case `_tree` is not set, skipping all analysis visitor walks. Use
1203+
* `symbolsOnly` when only definitions/calls/typeMap are needed (e.g. the
1204+
* this/super dispatch post-pass) to avoid the analysis overhead on the inline
1205+
* path, matching the optimization already applied to the worker-pool path.
12021206
*/
12031207
async function parseFilesWasmInline(
12041208
filePaths: string[],
12051209
rootDir: string,
1210+
symbolsOnly = false,
12061211
): Promise<Map<string, ExtractorOutput>> {
12071212
const result = new Map<string, ExtractorOutput>();
12081213
if (filePaths.length === 0) return result;
@@ -1220,7 +1225,12 @@ async function parseFilesWasmInline(
12201225
if (!extracted) continue;
12211226
const relPath = path.relative(rootDir, filePath).split(path.sep).join('/');
12221227
const symbols = extracted.symbols as ExtractorOutput & { _tree?: unknown; _langId?: string };
1223-
symbols._tree = extracted.tree;
1228+
// When symbolsOnly=true, skip setting _tree so runAnalyses does not run
1229+
// AST/complexity/CFG/dataflow visitor walks — only definitions/calls/typeMap
1230+
// are needed by callers like the this/super dispatch post-pass.
1231+
if (!symbolsOnly) {
1232+
symbols._tree = extracted.tree;
1233+
}
12241234
symbols._langId = extracted.langId;
12251235
result.set(relPath, symbols);
12261236
}
@@ -1246,7 +1256,7 @@ export async function parseFilesWasmForBackfill(
12461256
opts: { symbolsOnly?: boolean } = {},
12471257
): Promise<Map<string, ExtractorOutput>> {
12481258
if (filePaths.length <= INLINE_BACKFILL_THRESHOLD) {
1249-
return parseFilesWasmInline(filePaths, rootDir);
1259+
return parseFilesWasmInline(filePaths, rootDir, opts.symbolsOnly);
12501260
}
12511261
return parseFilesWasm(filePaths, rootDir, opts.symbolsOnly ? EXTRACT_ONLY : FULL_ANALYSIS);
12521262
}

0 commit comments

Comments
 (0)