Skip to content

Commit

Permalink
Small refactor to avoid reallocating a node for parseBlock
Browse files Browse the repository at this point in the history
Issue #656
  • Loading branch information
marijnh committed Sep 10, 2018
1 parent effe659 commit 5ba305b
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/statement.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ pp.parseStatement = function(context, topLevel, exports) {
return this.parseVarStatement(node, kind)
case tt._while: return this.parseWhileStatement(node)
case tt._with: return this.parseWithStatement(node)
case tt.braceL: return this.parseBlock()
case tt.braceL: return this.parseBlock(true, node)
case tt.semi: return this.parseEmptyStatement(node)
case tt._export:
case tt._import:
Expand Down Expand Up @@ -404,8 +404,7 @@ pp.parseExpressionStatement = function(node, expr) {
// strict"` declarations when `allowStrict` is true (used for
// function bodies).

pp.parseBlock = function(createNewLexicalScope = true) {
let node = this.startNode()
pp.parseBlock = function(createNewLexicalScope = true, node = this.startNode()) {
node.body = []
this.expect(tt.braceL)
if (createNewLexicalScope) this.enterScope(0)
Expand Down

0 comments on commit 5ba305b

Please sign in to comment.