Improve performance (#13376)

This commit is contained in:
Tobias Koppers 2021-05-27 03:04:58 +02:00 committed by GitHub
parent 4ee6a27780
commit dbfa87740c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -750,7 +750,7 @@ class BlockScoping {
getLetReferences() { getLetReferences() {
const block = this.block; const block = this.block;
let declarators = []; const declarators = [];
if (this.loop) { if (this.loop) {
const init = this.loop.left || this.loop.init; const init = this.loop.left || this.loop.init;
@ -773,7 +773,13 @@ class BlockScoping {
if (isBlockScoped(node)) { if (isBlockScoped(node)) {
convertBlockScopedToVar(path, node, block, this.scope); convertBlockScopedToVar(path, node, block, this.scope);
} }
declarators = declarators.concat(node.declarations || node); if (node.declarations) {
for (let i = 0; i < node.declarations.length; i++) {
declarators.push(node.declarations[i]);
}
} else {
declarators.push(node);
}
} }
if (t.isLabeledStatement(node)) { if (t.isLabeledStatement(node)) {
addDeclarationsFromChild(path.get("body"), node.body); addDeclarationsFromChild(path.get("body"), node.body);