Skip to content

Commit

Permalink
refactor: duplicated isNewLine code
Browse files Browse the repository at this point in the history
  • Loading branch information
JLHwung committed Aug 29, 2019
1 parent 4f6dcc4 commit 19690e8
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions packages/babel-parser/src/tokenizer/index.js
Expand Up @@ -280,13 +280,7 @@ export default class Tokenizer extends LocationParser {
const startLoc = this.state.curPosition();
let ch = this.input.charCodeAt((this.state.pos += startSkip));
if (this.state.pos < this.length) {
while (
ch !== charCodes.lineFeed &&
ch !== charCodes.carriageReturn &&
ch !== charCodes.lineSeparator &&
ch !== charCodes.paragraphSeparator &&
++this.state.pos < this.length
) {
while (!isNewLine(ch) && ++this.state.pos < this.length) {
ch = this.input.charCodeAt(this.state.pos);
}
}
Expand Down Expand Up @@ -452,13 +446,7 @@ export default class Tokenizer extends LocationParser {
let ch = this.input.charCodeAt(this.state.pos);
if (ch !== charCodes.exclamationMark) return false;

while (
ch !== charCodes.lineFeed &&
ch !== charCodes.carriageReturn &&
ch !== charCodes.lineSeparator &&
ch !== charCodes.paragraphSeparator &&
++this.state.pos < this.length
) {
while (!isNewLine(ch) && ++this.state.pos < this.length) {
ch = this.input.charCodeAt(this.state.pos);
}

Expand Down

0 comments on commit 19690e8

Please sign in to comment.