perf: Check for plugin only once before looping

This commit is contained in:
Daniel Tschinder 2019-01-16 02:11:46 -08:00
parent 10555c719e
commit 3a3d5cbe9c

View File

@ -865,6 +865,7 @@ export default class StatementParser extends ExpressionParser {
kind: TokenType,
): N.VariableDeclaration {
const declarations = (node.declarations = []);
const isTypescript = this.hasPlugin("typescript");
// $FlowFixMe
node.kind = kind.keyword;
for (;;) {
@ -879,7 +880,7 @@ export default class StatementParser extends ExpressionParser {
) {
// `const` with no initializer is allowed in TypeScript.
// It could be a declaration like `const x: number;`.
if (!this.hasPlugin("typescript")) {
if (!isTypescript) {
this.unexpected();
}
} else if (