Skip EmptyStatements in module initializers

This change skips emitting EmptyStatements into module initializers.
This serves no purpose and can in fact lead to us creating module
initializers that are nothing but a set of EmptyStatements, slowing
down initialization of them with no purpose.
This commit is contained in:
joeduffy 2017-01-13 07:22:38 -08:00
parent 8b1a814d17
commit 2097ab2f19
2 changed files with 6 additions and 5 deletions

View file

@ -390,8 +390,12 @@ export class Transformer {
this.currentModuleMembers[member.name.ident] = member;
}
else {
// This is a top-level module statement; place it into the module initializer.
statements.push(<ast.Statement>element);
// This is a top-level module statement; place it into the module initializer. Note that we
// skip empty statements just to avoid superfluously polluting the module with initializers.
let stmt = <ast.Statement>element;
if (stmt.kind !== ast.emptyStatementKind) {
statements.push(stmt);
}
}
}
}

View file

@ -287,9 +287,6 @@
"body": {
"kind": "Block",
"statements": [
{
"kind": "EmptyStatement"
},
{
"kind": "BinaryOperatorExpression",
"left": {