You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In greedy char loops, if the loop is followed by a known literal, when backtracking we LastIndexOf to find the next possible place to try to continue the match, rather than just backing up one char at a time. We can do the opposite for lazy char loops: rather than incrementing the position one char at a time, we can IndexOf{Any} for the following literal to find the next possible place to continue matching. In the case of a .? in Singleline, we can use IndexOf for the subsequent literal; in the case of a .? when not in Singeline, we can use IndexOfAny('\n', literal).
The text was updated successfully, but these errors were encountered:
Tagging subscribers to this area: @dotnet/area-system-text-regularexpressions
See info in area-owners.md if you want to be subscribed.
Issue Details
In greedy char loops, if the loop is followed by a known literal, when backtracking we LastIndexOf to find the next possible place to try to continue the match, rather than just backing up one char at a time. We can do the opposite for lazy char loops: rather than incrementing the position one char at a time, we can IndexOf for the following literal to find the next possible place to continue matching.
stephentoub
changed the title
Regex source generator can use IndexOf to speed up lazy loop
Regex compiler / source generator can use IndexOf to speed up lazy loop
Dec 13, 2021
In greedy char loops, if the loop is followed by a known literal, when backtracking we LastIndexOf to find the next possible place to try to continue the match, rather than just backing up one char at a time. We can do the opposite for lazy char loops: rather than incrementing the position one char at a time, we can IndexOf{Any} for the following literal to find the next possible place to continue matching. In the case of a .? in Singleline, we can use IndexOf for the subsequent literal; in the case of a .? when not in Singeline, we can use IndexOfAny('\n', literal).
The text was updated successfully, but these errors were encountered: