Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixed tokeniser optimisation when scanning for missing data element c…
…lose tags.

Fixes jhy#67
  • Loading branch information
jhy committed Jan 18, 2011
1 parent 7938bae commit c755b04
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/main/java/org/jsoup/parser/TokenQueue.java
Expand Up @@ -201,13 +201,16 @@ public String consumeToIgnoreCase(String seq) {
int start = pos;
String first = seq.substring(0, 1);
boolean canScan = first.toLowerCase().equals(first.toUpperCase()); // if first is not cased, use index of
while (!isEmpty() && !matches(seq)) {
while (!isEmpty()) {
if (matches(seq))
break;

if (canScan) {
int skip = queue.indexOf(first, pos) - pos;
if (skip <= 0)
if (skip == 0) // this char is the skip char, but not match, so force advance of pos
pos++;
else if (skip < 0) // no chance of finding, grab to end
pos = queue.length() - 1;
pos = queue.length();
else
pos += skip;
}
Expand Down

0 comments on commit c755b04

Please sign in to comment.