Skip to content

Commit

Permalink
perf: simplify the skip functions
Browse files Browse the repository at this point in the history
  • Loading branch information
lddubeau committed Aug 14, 2018
1 parent ac03a1c commit c7b8c3b
Showing 1 changed file with 8 additions and 22 deletions.
30 changes: 8 additions & 22 deletions lib/saxes.js
Original file line number Diff line number Diff line change
Expand Up @@ -572,21 +572,14 @@ class SaxesParser {
*/
skipWhile(chunkState, test) {
const { limit } = chunkState;
let c;
// eslint-disable-next-line no-constant-condition
while (true) {
if (chunkState.i >= limit) {
c = undefined;
break;
}

c = this.getCode(chunkState);
while (chunkState.i < limit) {
const c = this.getCode(chunkState);
if (!test(c)) {
break;
return c;
}
}

return c;
return undefined;
}

/**
Expand All @@ -601,21 +594,14 @@ class SaxesParser {
*/
skipWhitespace(chunkState) {
const { limit } = chunkState;
let c;
// eslint-disable-next-line no-constant-condition
while (true) {
if (chunkState.i >= limit) {
c = undefined;
break;
}

c = this.getCode(chunkState);
while (chunkState.i < limit) {
const c = this.getCode(chunkState);
if (!isS(c)) {
break;
return c;
}
}

return c;
return undefined;
}


Expand Down

0 comments on commit c7b8c3b

Please sign in to comment.