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:
Daniel Tschinder
2019-01-17 01:46:22 -08:00
parent b66d921053
commit 4e5e319d5b
4 changed files with 70 additions and 84 deletions

View File

@@ -24,6 +24,7 @@ import LValParser from "./lval";
import {
isStrictReservedWord,
isStrictBindReservedWord,
isKeyword,
} from "../util/identifier";
import type { Pos, Position } from "../util/location";
import * as charCodes from "charcodes";
@@ -2020,7 +2021,7 @@ export default class ExpressionParser extends LValParser {
);
}
if (this.isReservedWord(word) || (checkKeywords && this.isKeyword(word))) {
if (this.isReservedWord(word) || (checkKeywords && isKeyword(word))) {
this.raise(startLoc, word + " is a reserved word");
}
}