feat(cjs-module-analyzer): Avoid stack allocations
MODIFY
packages/lexer/src/lexer.js
packages/lexer/src/lexer.js
@@ -12,10 +12,10 @@ let openTokenDepth;
let templateDepth;
let lastTokenPos;
let lastSlashWasDivision;
-let templateStack;
+const templateStack = new Array(1024);
let templateStackDepth;
-let openTokenPosStack;
-let openClassPosStack;
+const openTokenPosStack = new Array(1024);
+const openClassPosStack = new Array(1024);
let nextBraceIsClass;
let starExportMap;
let lastStarExportSpecifier;
@@ -29,10 +29,10 @@ function resetState() {
templateDepth = -1;
lastTokenPos = -1;
lastSlashWasDivision = false;
- templateStack = new Array(1024);
+ templateStack.length = 0;
templateStackDepth = 0;
- openTokenPosStack = new Array(1024);
- openClassPosStack = new Array(1024);
+ openTokenPosStack.length = 0;
+ openClassPosStack.length = 0;
nextBraceIsClass = false;
starExportMap = Object.create(null);
lastStarExportSpecifier = null;

feat(cjs-module-analyzer): Avoid stack allocations