Skip to content

Commit

Permalink
Save a little time - that verification hasn't fired to date
Browse files Browse the repository at this point in the history
  • Loading branch information
jhy committed Feb 23, 2020
1 parent ebd2a77 commit 5127814
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/main/java/org/jsoup/parser/Tokeniser.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,8 @@ final class Tokeniser {
}

Token read() {
final CharacterReader r = this.reader;
final int pos = r.pos(); // count how many reads we do in a row without making progress, and bail if stuck in a loop
int consecutiveReads = 0;
while (!isEmitPending) {
state.read(this, r);
if (++consecutiveReads > 10 && r.pos() <= pos)
Validate.wtf("BUG: Not making progress from state: " + this.state.name() + " with current char=" + r.current());
state.read(this, reader);
}

// if emit is pending, a non-character token was found: return any chars in buffer, and leave token for next read:
Expand All @@ -80,7 +75,7 @@ Token read() {
}

void emit(Token token) {
Validate.isFalse(isEmitPending, "There is an unread token pending!");
Validate.isFalse(isEmitPending);

emitPending = token;
isEmitPending = true;
Expand Down

0 comments on commit 5127814

Please sign in to comment.