perf: remove double check for keywords in readWord
Instead of calling isKeyword we simple check directly if the keyword token is available
This commit is contained in:
@@ -1190,9 +1190,6 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
case "any":
|
||||
return this.finishNode(node, "AnyTypeAnnotation");
|
||||
|
||||
case "void":
|
||||
return this.finishNode(node, "VoidTypeAnnotation");
|
||||
|
||||
case "bool":
|
||||
case "boolean":
|
||||
return this.finishNode(node, "BooleanTypeAnnotation");
|
||||
@@ -1369,6 +1366,10 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
"NumberLiteralTypeAnnotation",
|
||||
);
|
||||
|
||||
case tt._void:
|
||||
this.next();
|
||||
return this.finishNode(node, "VoidTypeAnnotation");
|
||||
|
||||
case tt._null:
|
||||
this.next();
|
||||
return this.finishNode(node, "NullLiteralTypeAnnotation");
|
||||
@@ -1922,16 +1923,6 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
}
|
||||
}
|
||||
|
||||
// don't consider `void` to be a keyword as then it'll use the void token type
|
||||
// and set startExpr
|
||||
isKeyword(name: string): boolean {
|
||||
if (this.state.inType && name === "void") {
|
||||
return false;
|
||||
} else {
|
||||
return super.isKeyword(name);
|
||||
}
|
||||
}
|
||||
|
||||
// ensure that inside flow types, we bypass the jsx parser plugin
|
||||
getTokenFromCode(code: number): void {
|
||||
const next = this.state.input.charCodeAt(this.state.pos + 1);
|
||||
|
||||
Reference in New Issue
Block a user