Skip to content

Commit 854c198

Browse files
committed
Refactor block statement construction in compiler
Replaces array spread with manual array construction for block statements, improving clarity and potentially performance when combining tryBlock and dispatchStmts.
1 parent 8e1c660 commit 854c198

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/compiler.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3297,10 +3297,12 @@ export class Compiler extends DiagnosticEmitter {
32973297
dispatchStmts.push(module.unreachable());
32983298
}
32993299

3300-
let fullBlock = module.block(null, [
3301-
tryBlock,
3302-
...dispatchStmts
3303-
]);
3300+
let fullBlockStmts = new Array<ExpressionRef>(1 + dispatchStmts.length);
3301+
fullBlockStmts[0] = tryBlock;
3302+
for (let i = 0; i < dispatchStmts.length; i++) {
3303+
fullBlockStmts[1 + i] = dispatchStmts[i];
3304+
}
3305+
let fullBlock = module.block(null, fullBlockStmts);
33043306

33053307
// Merge flow states
33063308
// If finally always terminates, the whole construct terminates

0 commit comments

Comments
 (0)