Skip to content

Commit

Permalink
Make DFA use hints.
Browse files Browse the repository at this point in the history
Change-Id: I7b7b338a019ea19c4a99072c961dc6aa35c15915
Reviewed-on: https://code-review.googlesource.com/c/re2/+/49950
Reviewed-by: Paul Wankadia <[email protected]>
  • Loading branch information
junyer committed Dec 30, 2019
1 parent 7470f4d commit f71aaa0
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions re2/dfa.cc
Original file line number Diff line number Diff line change
Expand Up @@ -971,8 +971,21 @@ void DFA::RunWorkqOnByte(Workq* oldq, Workq* newq,
break;

case kInstByteRange: // can follow if c is in range
if (ip->Matches(c))
AddToQueue(newq, ip->out(), flag);
if (!ip->Matches(c))
break;
AddToQueue(newq, ip->out(), flag);
if (ip->hint() != 0) {
// We have a hint, but we must cancel out the
// increment that will occur after the break.
i += ip->hint() - 1;
} else {
// We have no hint, so we must find the end
// of the current list and then skip to it.
Prog::Inst* ip0 = ip;
while (!ip->last())
++ip;
i += ip - ip0;
}
break;

case kInstMatch:
Expand Down

0 comments on commit f71aaa0

Please sign in to comment.