Miscellaneous perf tweak (#10421)
* refactor: early return on hot path * refactor: read next2 only when next is dot * perf: mini refactor
This commit is contained in:
parent
610d6bdc62
commit
4395c22f3a
@ -39,10 +39,11 @@ export default class CommentsParser extends BaseParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
adjustCommentsAfterTrailingComma(node: Node, elements: Node[]) {
|
adjustCommentsAfterTrailingComma(node: Node, elements: Node[]) {
|
||||||
if (elements.length === 0) {
|
if (this.state.leadingComments.length === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (this.state.leadingComments.length === 0) {
|
|
||||||
|
if (elements.length === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -234,8 +234,8 @@ export default class Tokenizer extends LocationParser {
|
|||||||
skipBlockComment(): void {
|
skipBlockComment(): void {
|
||||||
const startLoc = this.state.curPosition();
|
const startLoc = this.state.curPosition();
|
||||||
const start = this.state.pos;
|
const start = this.state.pos;
|
||||||
const end = this.input.indexOf("*/", (this.state.pos += 2));
|
const end = this.input.indexOf("*/", this.state.pos + 2);
|
||||||
if (end === -1) this.raise(this.state.pos - 2, "Unterminated comment");
|
if (end === -1) this.raise(start, "Unterminated comment");
|
||||||
|
|
||||||
this.state.pos = end + 2;
|
this.state.pos = end + 2;
|
||||||
lineBreakG.lastIndex = start;
|
lineBreakG.lastIndex = start;
|
||||||
@ -404,8 +404,10 @@ export default class Tokenizer extends LocationParser {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const next2 = this.input.charCodeAt(this.state.pos + 2);
|
if (
|
||||||
if (next === charCodes.dot && next2 === charCodes.dot) {
|
next === charCodes.dot &&
|
||||||
|
this.input.charCodeAt(this.state.pos + 2) === charCodes.dot
|
||||||
|
) {
|
||||||
this.state.pos += 3;
|
this.state.pos += 3;
|
||||||
this.finishToken(tt.ellipsis);
|
this.finishToken(tt.ellipsis);
|
||||||
} else {
|
} else {
|
||||||
@ -900,9 +902,9 @@ export default class Tokenizer extends LocationParser {
|
|||||||
let val;
|
let val;
|
||||||
|
|
||||||
if (this.hasPlugin("numericSeparator")) {
|
if (this.hasPlugin("numericSeparator")) {
|
||||||
const prev = this.input.charCodeAt(this.state.pos - 1);
|
|
||||||
const next = this.input.charCodeAt(this.state.pos + 1);
|
|
||||||
if (code === charCodes.underscore) {
|
if (code === charCodes.underscore) {
|
||||||
|
const prev = this.input.charCodeAt(this.state.pos - 1);
|
||||||
|
const next = this.input.charCodeAt(this.state.pos + 1);
|
||||||
if (allowedSiblings.indexOf(next) === -1) {
|
if (allowedSiblings.indexOf(next) === -1) {
|
||||||
this.raise(this.state.pos, "Invalid or unexpected token");
|
this.raise(this.state.pos, "Invalid or unexpected token");
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user