perf: Ensure canInsertSemicolon is always called last
It does a lot of checks and a regex test
This commit is contained in:
parent
455e003567
commit
58768072ef
@ -869,9 +869,9 @@ export default class ExpressionParser extends LValParser {
|
|||||||
return this.parseFunction(node, false, false, true);
|
return this.parseFunction(node, false, false, true);
|
||||||
} else if (
|
} else if (
|
||||||
canBeArrow &&
|
canBeArrow &&
|
||||||
!this.canInsertSemicolon() &&
|
|
||||||
id.name === "async" &&
|
id.name === "async" &&
|
||||||
this.match(tt.name)
|
this.match(tt.name) &&
|
||||||
|
!this.canInsertSemicolon()
|
||||||
) {
|
) {
|
||||||
const oldYOAIPAP = this.state.yieldOrAwaitInPossibleArrowParameters;
|
const oldYOAIPAP = this.state.yieldOrAwaitInPossibleArrowParameters;
|
||||||
const oldInAsync = this.state.inAsync;
|
const oldInAsync = this.state.inAsync;
|
||||||
@ -886,7 +886,8 @@ export default class ExpressionParser extends LValParser {
|
|||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (canBeArrow && !this.canInsertSemicolon() && this.eat(tt.arrow)) {
|
if (canBeArrow && this.match(tt.arrow) && !this.canInsertSemicolon()) {
|
||||||
|
this.next();
|
||||||
const oldYOAIPAP = this.state.yieldOrAwaitInPossibleArrowParameters;
|
const oldYOAIPAP = this.state.yieldOrAwaitInPossibleArrowParameters;
|
||||||
this.state.yieldOrAwaitInPossibleArrowParameters = null;
|
this.state.yieldOrAwaitInPossibleArrowParameters = null;
|
||||||
this.parseArrowExpression(node, [id]);
|
this.parseArrowExpression(node, [id]);
|
||||||
@ -2076,8 +2077,8 @@ export default class ExpressionParser extends LValParser {
|
|||||||
this.next();
|
this.next();
|
||||||
if (
|
if (
|
||||||
this.match(tt.semi) ||
|
this.match(tt.semi) ||
|
||||||
this.canInsertSemicolon() ||
|
(!this.match(tt.star) && !this.state.type.startsExpr) ||
|
||||||
(!this.match(tt.star) && !this.state.type.startsExpr)
|
this.canInsertSemicolon()
|
||||||
) {
|
) {
|
||||||
node.delegate = false;
|
node.delegate = false;
|
||||||
node.argument = null;
|
node.argument = null;
|
||||||
|
|||||||
@ -1398,7 +1398,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
|||||||
const startPos = this.state.start,
|
const startPos = this.state.start,
|
||||||
startLoc = this.state.startLoc;
|
startLoc = this.state.startLoc;
|
||||||
let type = this.flowParsePrimaryType();
|
let type = this.flowParsePrimaryType();
|
||||||
while (!this.canInsertSemicolon() && this.match(tt.bracketL)) {
|
while (this.match(tt.bracketL) && !this.canInsertSemicolon()) {
|
||||||
const node = this.startNodeAt(startPos, startLoc);
|
const node = this.startNodeAt(startPos, startLoc);
|
||||||
node.elementType = type;
|
node.elementType = type;
|
||||||
this.expect(tt.bracketL);
|
this.expect(tt.bracketL);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user