Skip to content

Commit 5baf98c

Browse files
committed
perf(native): remove .prototype. files from WASM post-pass filter
The Rust engine now extracts `Foo.prototype.bar = fn` definitions natively (PR #1327). Remove the `.prototype.` text filter from the `runPostNativePrototypeMethods` pre-filter so those files are no longer WASM-reparsed on every native build. The function-as-object-property pattern (`fn.method = function(){}`) is still not handled by Rust and continues to use the WASM post-pass. This eliminates the 422% Build ms/file regression seen on CI.
1 parent 8dcc760 commit 5baf98c

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

src/domain/graph/builder/stages/native-orchestrator.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ async function runPostNativePrototypeMethods(
576576
db: BetterSqlite3Database,
577577
rootDir: string,
578578
): Promise<void> {
579-
// Collect JS/TS file paths from the DB — only extensions where prototype
579+
// Collect JS/TS file paths from the DB — only extensions where these
580580
// patterns can appear.
581581
const jsExts = new Set(['.js', '.mjs', '.cjs', '.ts', '.tsx']);
582582
const fileRows = db
@@ -591,15 +591,14 @@ async function runPostNativePrototypeMethods(
591591

592592
if (jsFiles.length === 0) return;
593593

594-
// Quick pre-filter: only re-parse files that actually contain prototype or
595-
// function-as-object-property patterns to avoid an expensive WASM re-parse of
596-
// every JS/TS file in large repos. Covers:
597-
// - `.prototype.` — classical prototype method assignment
598-
// - `\b\w+\.\w+\s*=\s*function` — function-as-object property (`f.g = function(){}`)
594+
// Pre-filter: only re-parse files that contain the function-as-object-property
595+
// pattern (`fn.method = function() {}`). The Rust engine now handles
596+
// `Foo.prototype.bar = fn` natively, so `.prototype.` files no longer need
597+
// a WASM re-parse here.
599598
const protoFiles = jsFiles.filter((relPath) => {
600599
try {
601600
const content = readFileSafe(path.join(rootDir, relPath));
602-
return content.includes('.prototype.') || /\b\w+\.\w+\s*=\s*function/.test(content);
601+
return /\b\w+\.\w+\s*=\s*function/.test(content);
603602
} catch {
604603
return false;
605604
}
@@ -1390,13 +1389,14 @@ export async function tryNativeOrchestrator(
13901389
}
13911390
}
13921391

1393-
// Prototype method post-pass: the Rust engine does not recognise pre-ES6
1394-
// `Foo.prototype.bar = function(){}` patterns. Re-parse JS/TS files via
1395-
// WASM to insert missing method nodes and their call edges.
1392+
// Function-as-object-property post-pass: the Rust engine does not yet recognise
1393+
// `fn.method = function() {}` patterns. Re-parse only those JS/TS files via
1394+
// WASM to insert missing method nodes. `Foo.prototype.bar = fn` is now
1395+
// handled natively by the Rust extractor and no longer needs a WASM re-parse.
13961396
try {
13971397
await runPostNativePrototypeMethods(ctx.db as unknown as BetterSqlite3Database, ctx.rootDir);
13981398
} catch (err) {
1399-
debug(`Prototype methods post-pass failed: ${toErrorMessage(err)}`);
1399+
debug(`Function-prop methods post-pass failed: ${toErrorMessage(err)}`);
14001400
}
14011401

14021402
// Backfill the `technique` column on `calls` edges written by the Rust

0 commit comments

Comments
 (0)