Skip to content

Commit

Permalink
perf: optimize onlyWhyspaceRemainsOnLine helper
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanPiercey committed Feb 9, 2022
1 parent c1bc541 commit c74da83
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/core/Parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,13 @@ export class Parser {
}

onlyWhitespaceRemainsOnLine(offset = 1) {
return /^\s*\n/.test(this.substring(this.pos + offset));
for (let i = this.pos + offset; i < this.maxPos; i++) {
const code = this.data.charCodeAt(i);
if (code === CODE.NEWLINE) return true;
if (!isWhitespaceCode(code)) break;
}

return false;
}

consumeWhitespace() {
Expand Down

0 comments on commit c74da83

Please sign in to comment.