perf: Ensure canInsertSemicolon is always called last

It does a lot of checks and a regex test
This commit is contained in:
Daniel Tschinder
2019-01-15 23:32:18 -08:00
parent 455e003567
commit 58768072ef
2 changed files with 7 additions and 6 deletions

View File

@@ -1398,7 +1398,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
const startPos = this.state.start,
startLoc = this.state.startLoc;
let type = this.flowParsePrimaryType();
while (!this.canInsertSemicolon() && this.match(tt.bracketL)) {
while (this.match(tt.bracketL) && !this.canInsertSemicolon()) {
const node = this.startNodeAt(startPos, startLoc);
node.elementType = type;
this.expect(tt.bracketL);