Simplify token context (#13450)

* refactor: unify tc.brace and tc.templateQuasi

* refactor: remove unused context check

* perf: reduce arrayPrototype call and hoist variables
This commit is contained in:
Huáng Jùnliàng
2021-06-21 10:51:00 -04:00
committed by GitHub
parent 8c229e7657
commit 5145c98a73
5 changed files with 29 additions and 46 deletions

View File

@@ -127,10 +127,10 @@ export default class State {
lastTokStart: number = 0;
lastTokEnd: number = 0;
// The context stack is used to superficially track syntactic
// context to predict whether a regular expression is allowed in a
// given position.
// The context stack is used to track whether the apostrophe "`" starts
// or ends a string template
context: Array<TokContext> = [ct.brace];
// Used to track whether a JSX element is allowed to form
exprAllowed: boolean = true;
// Used to signal to callers of `readWord1` whether the word