Skip to content

Regex compiler / source generator can use IndexOf to speed up lazy loop #62669

Description

@stephentoub

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).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions